Dynamically inserting columns with attached header to a grid


I want to dynamically insert columns to the grid and each column that I add have two standard sub headers. I am able to add a column dynamically but I don’t know how to add the sub header using the grid.attachHeader(…) to the column added.

The piece of code below shows only one sub-header under each column, but I want to show two sub-header under each column that i have added,


for(int m=0;m<arrUnitList.length;m++)


            String unitIdKey = (String) arrUnitList[m];

            Hashtable deptHash = (Hashtable) earnCodeHash.get(unitIdKey);

            Set deptKeys = deptHash.keySet();

            Object[] arrDeptList = deptKeys.toArray();            






Pls help me solving this issue,


The columns added to the grid will have the same count of rows in header as existing grid has.
So you need to have the header with two additional lines in header ( which can be combined by rowspans ) - in such case newly added column will have necessary column count.

Can you be more specific. Or if possible can you provide some sample code for this.

mygrid.insertColumn(8,“text 1”,“ro”,100)


I don’t want two sub-header columns (text 2, text 3) one below the other which is below the main header column(text 1). What I need is ‘text 1’ column divided into ‘text 2’ and ‘text 3’.
And this main header column like ‘text 1’ should be dynamically inserted into the grid and can be inserted ‘n’ number of times.

Awaiting for your response.

To achieve such effect you will need to create a colspan in top header row, but in not possible to include column in top level colspan by insertColumn operation.
The only way to achieve such usecase - create grid with necessary configuration by grid.setHeader(…)

dhtmlx.com/docs/products/dhtmlxG … art_hdrftr