Make column bold

Hello,



I’d like to add a style element to a column similarly to the way a row is set bold using setRowTextBold. Is it possible to do that for a column?



Thanks

There is no special method to set style for the column. But you can try to use the following:
 
mygrid.forEachRow(function(id){
 
    mygrid.setCellTextStyle(id,COLUMN_INDEX,"font:bold;")
 
})

Hi, Thanks for the quick reply. I tried it but doesn’t work. This is my code. I want column 2 to be set to italic. I tried putting that code snippet before loadXML and after but doesn’t make any difference. Where have I gone wrong?

            mygrid = new dhtmlXGridObject(‘gridbox’);
            mygrid.setImagePath(“codebase/imgs/”);
            mygrid.setHeader(“An,An,An,An,An”);
            mygrid.setInitWidths(“80,80,80,80,80”)
            mygrid.setColAlign(“right,right,right,right,right”)
            mygrid.setColTypes(“ro,math,math,dyn[=c1-c2],ro”);
            mygrid.setColumnIds(“an,totdob,totchir,totdobchirdif,totdobchircmt”)
            mygrid.enableMathEditing(false);
            mygrid.setMathRound(0);
            mygrid.setSkin(“light”);
            mygrid.init();
            mygrid.loadXML(“php/xml_rezultate_totdob.php”);
            mygrid.forEachRow(function(id){
                mygrid.setCellTextStyle(id,2,“font-style:italic;”)
            });

            myDataProcessor = new dataProcessor(“php/update_rezultate_totdob.php”);
            myDataProcessor.enableDataNames(true);
            myDataProcessor.setUpdateMode(“cell”);//available values: cell (default), row, off
            myDataProcessor.defineAction(“error”,myErrorHandler);
            myDataProcessor.setTransactionMode(“GET”);
            myDataProcessor.init(mygrid);


It is necessary to carry out operations with rows  only when xml loading  is ended. 

You can place code for changing column style in the “onXLE” event handler or in the second parameter of the loadXML method:

  mygrid.loadXML(“php/xml_rezultate_totdob.php”, function(){

            mygrid.forEachRow(function(id){

                mygrid.setCellTextStyle(id,2,“font-style:italic;”)

            });

})

That’s perfect. Now it works. Thanks. Would it also be possible for the style to extend to the corresponding column header?

Unfortunately,  there is no such an opportunity.

But you can place any html inside header cell. For example:

mygrid.setHeader(“An,An,

An
,An,An”);