Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Nagh on Feb 19, 2008 09:45
open dhtmlx forum
adding more columns to existing grid

I have existing grid, for complex reason I won't use xml configuration.

How I should add column to the existing grid, change its properties and reload it with data.

I have tried:
grid.insertColumn(0, "header","ro",100);
column are added, but then I receive repeated JS error: Invalid argument
in following function:
this.chngCellWidth = function(){
if ((_isOpera)&&(this.ftr))
this.ftr.width=this.objBox.scrollWidth+"px";
var l=this._cCount;
for(var i=0;i<l;i++){
this.hdr.rows[0].cells[i].style.width = this.cellWidthPX[i]+"px"; // Error on this line - Invalid argument
this.obj.rows[0].childNodes[i].style.width = this.cellWidthPX[i]+"px";
if (this.ftr)
this.ftr.rows[0].cells[i].style.width = this.cellWidthPX[i]+"px";
}
}
------
In JS debugger I can see that this.cellWidthPX[i] has value "NaN".

Perhaps I should do something more then just calling insertColumn?

Thank you.
Answer posted by Support on Feb 20, 2008 04:18
>>Perhaps I should do something more then just calling insertColumn?

Actually this is must be enough in most cases. ( The same code line works fine for me )
The similar problem was confirmed and fixed for dhtmlxgrid 1.4 - If you are using not latest code - please contact us directly ( at support@dhtmlx.com ) - we will provide fixed version of necessary extenstion.

If problem occurs for you with latest version of code - please provide any kind of sample where it can be reconstructed.
Answer posted by Nagh on Feb 20, 2008 06:35
We are using grid v.1.5 build 71114, I guess its should be up2date.

While trying to build testcase for you, I have discovered that it happens only if I set initial width for columns in percent.

Following setting will cause JS error, if you try to add new column:
grid.setInitWidthsP("15,*")

Answer posted by Support on Feb 20, 2008 06:55
Problem confirmed and fixed - please contact us directly at support@dhtmlx.com and provide your ref. number - we will send you updated js file.
Answer posted by Nagh on Feb 22, 2008 04:17
There is additional issue arise within the fix, somehow related to question, regarding sorting arrow.
http://www.dhtmlx.com/docs/products/kb/index.php?s=normal&q=1806

While I still building testcase, one more question still remains.
When I'm inserting a column, I can state before which column I want it to be inserted, but when I load new data with XML, this column will be always last.
Is it intended by design, or the some feature to adjust this behavior ?

Thanks
Answer posted by Support on Feb 22, 2008 08:59
>>Is it intended by design, or the some feature to adjust this behavior ?
By default component preserves original XML format ( it may not have sense in your case, but useful in case of dynamic loading or smart-rendering, where we need not change server side configuration, even if new column inserted )

Please check
    http://dhtmlx.com/docs/products/kb/index.shtml?cat=recent&q=2138