Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Tejas Shah on Aug 06, 2008 11:25
open dhtmlx forum
DHTMLX Grid : Resize the column dynamically and style.

Hi there,
Actually I want to resize the column width automatically when I add the column dynamically.
:: Means suppose I am setting widths thru setInitWidthsP and I add the column dynamically thru some click, then I want added column to adjust its width automatically. Example : 4 columns each with 25% width and suppose I add fifth column then automatically all rows width % shud be 20.
:: Also I have set the column color thru grid.setColumnColor("#F7EBBA,white,white,white");
So how to give same style to the newly added column >????
How to do this ?
Answer posted by Support on Aug 07, 2008 01:23
>> I add fifth column then automatically all rows width % shud be 20.
You need to set initial width as
mygrid.setInitWidths("*,*,*,*")
and use * as size for newly added column, in such case all columns take equal size to fill all available space. 

>>So how to give same style to the newly added column >????
9th parameter of insertColumn command - columnColor
Answer posted by Tejas Shah on Aug 07, 2008 06:08
Hi,
     Can I give color to the header also while adding column using insertColumn() ????
Answer posted by Support on Aug 07, 2008 06:16
Insert column doesn't allow to set such parameter. 
You can access and set color directly to DOM element after column adding as
     grid.hdr.rows[1].cells[index].style.backgroundColor="color";
Answer posted by Tejas Shah on Aug 09, 2008 04:25
Hi,
     I used following to change the color of the column (added through script)
     <gridObject>.hdr.rows[1].cells[index].style.backgroundColor="color"; but after adding some say 5-6 columns, it stops changing the color of the header. Why it happens ?
 

Answer posted by Support on Aug 11, 2008 07:07
It must work correctly for any count of columns
If you are using colspans or rowspans in grid's header - beware that index is "actual" not "nominal" column index.
( if you have 1st and 2nd columns combined in colspan, the index of 3rd column will be 1 )