Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Janice on Mar 21, 2008 08:36
open dhtmlx forum
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
Answer posted by Supprt on Mar 21, 2008 09:01
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;")
 
})
Answer posted on Mar 21, 2008 09:25
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);


Answer posted by Support on Mar 21, 2008 09:37
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;")

            });

})
Answer posted on Mar 21, 2008 09:56
That's perfect. Now it works. Thanks. Would it also be possible for the style to extend to the corresponding column header?
Answer posted by Support on Mar 21, 2008 10:02
Unfortunately,  there is no such an opportunity.

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

mygrid.setHeader("An,An,<div style='font-style:italic'>An</div>,An,An");