Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Vikram on Apr 30, 2009 01:42
open dhtmlx forum
Grid Negative Numbers in Red

Hi,

I have a column in a grid having both positive and negative numbers.The bottom of the grid contains a footer with total's for each column.I would like to know if I can replace any negative number within a bracket just like -1234 becomes (1234) with the colour of the value appearing in red.

However any custom styling would affect the totaling as we have used the #stat_total to perform a summation.Changing it to (1234) should not affect the totaling.


Regards,

Vikram
Answer posted by Support on Apr 30, 2009 03:08
>>if I can replace any negative number within a bracket
It possible to use onCellChanged or onRowCreated event to dynamically change the data of cell 

grid.attachEvent("onCellChanged",functon(id,ind,value){
   if (ind == INDEX && value*1 < 0 ){
           this.cells(id,ind).cell.innerHTML="("+value+")";
           this.cells(id,ind).cell.style.color="red";
    }
})

>>However any custom styling would affect the totaling as we have used the #stat_total 
Adding red color in above way, will not affect totaling, but adding "(" ")" will break summation logic ( because value will not be identified as valid number anymore ) 

The more complex solution, which will work correctly for both rendering and summation can be done through custom excells - in such case you will be able to define custom rendering rules and maintain valid numeric representation in the same time. 

http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Custom_excell_creation.html#grid_cexc


Answer posted by Vikram on May 19, 2009 06:49
I works well, but we have a problem. When I enable smart rendering only the first set of rendered rows have the custom style. How do we handle the styling for the other rows.
Answer posted by Alex (support) on May 19, 2009 07:28

Are you sure that xml contains "style" attribute for all rows ?

Please, provide some details: how do you set style? and what grid version do you use ?