[solved] setcolalign for all columns

Hi,

I start a dhtmlxgrid from a defined HTML-table. Everything works, with the code below:

            "<script>" +
            "var grid = new dhtmlXGridFromTable('result_table');" +
            "grid.enableAutoWidth(true);" +
            "grid.enableAutoHeight(true);" +
            "grid.setSizes();" +
            "grid.setColTypes('ro');" +
            "grid.setColAlign(\"right\");" + :exclamation:
            "grid.setSkin(\"modern\");" +
            "</script>");

except for the setcolalign-value. I want to set a predefined setcolalign for all my columns, as I don’t know the number of columns I will have, because these will automatically be generated by some Java-classes

There is no way to set alignment for all columns. setColAlign() method is called after HTML table already generated, right? So by the time of script execution you already know number of columns in grid.

Ok, thanks for the reply. I can indeed do it in the way that you say

Now I have tried the much more simpler variant ( at least i thought so ) , in this case for 7 columns:

            "<script>" +
            "grid = new dhtmlXGridFromTable('result_table');" +
            "grid.enableAutoWidth(true);" +
            "grid.enableAutoHeight(true);" +
            "grid.setSizes();" + 
            "grid.setColTypes('ro');" + 
            "grid.setSkin(\"modern\");" +  
            "grid.setColAlign(\"left,left,left,left,left,center,center\");" +  :exclamation: 
            "</script>");

This example worked perfect in my hardcoded HTML-page, but then I used
mygrid = new dhtmlXGridObject(‘mygrid_container’);
and now I use
grid = new dhtmlXGridFromTable(‘result_table’);
Is there a difference somehow that causes the setcolalign function to not work anymore?

I found my solution in adding text-align: center; to div.gridbox table.obj tr td in the CSS

setColAlign() method should be called before grid initialization. In case of initialization from HTML table, init() method is called when you initialize grid object (dhtmlXGridFromTable). To call setColAlign() before initialization of the grid you should use following code:

[code]


… [/code]

Please find more information here docs.dhtmlx.com/doku.php?id=dhtm … _from_html