Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Carmine Marino on Jul 07, 2008 10:19
open dhtmlx forum
grid us dollar sorting and formatting

We purchased the DHTMLX suite. We are using the grid control to display dollar amounts. I pass the data via xml. For the dollar amounts, I pass them without formatting. Simple floats.

For the ColTypes I specify "price" and ColSorting I specify "int". Sorting is working fine.

    paymentHistoryGrid.setColTypes("ro,ro,price,ro,ro,ro,ro,ro");
    paymentHistoryGrid.setColSorting("str,str,int,int,na,na,str,int");

The problem is the I am not seeing the commas per thousand i.e.,$2,000,291.00. How do I get formatting to work this way? I tried using numberFormat, but that didn't work. It seems to only work with eon/ron.

If I put the commas into the value in the xml cell. Sorting doesn't work right. We'd use ron or edn, but we want the color coding that's associcated with price.

thank you,
Carmine Marino
Answer posted by Support on Jul 08, 2008 01:41
>> How do I get formatting to work this way?
Specify column type as edn, and add next command to grid init
    grid.setNumberFormat("$0,000.00",2);

>> It seems to only work with eon/ron.
Yes, but you can have any additional chars as part of format, so result will look the same as with "price" column type.

>> We'd use ron or edn, but we want the color coding that's associcated with price.
grid.attachEvent("onCellChanged",function(id,ind,value){
    grid.cells(id,ind).cell.style.backgroundColor = value>0?"green":"red";
});