Sorting does not work for custom eXcell type

Hi ,

This is the function Im writing to create a custom eXcell type for price.
The aim is to have a comma seperator for the number and the $ symbol as well.
So 123456 is displayed as $123,456. But once I implement this , the inbuilt sort in my dhtmlx grid fails to work :frowning:
Is there a solution . Pls help!

function thousandSeparator(num) {
var o=num;
num = num.toString().replace(/$|,/g,’’);
if(isNaN(num) || num==’’) return o;

            num=Math.round(num)

sign = (num == (num=Math.abs(num)));
num=num.toString();

            for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)

num = num.substring(0,num.length-(4i+3))+’,’+ num.substring(num.length-(4i+3));
return (sign>0?’’:’-’)+num+’’ ;
}

function eXcell_myprice(cell) {
this.base = eXcell_price;
this.base(cell);
this.setValue = function(val) {

    if(val.toString().trim()==""){
      val = "&nbsp;";
      this.cell.innerHTML = val; 
   } 
   else{
       val="$"+thousandSeparator(val);
       this.cell.innerHTML = val;
   }
   this.cell.innerHTML = this.grid._aplNF(val, this.cell._cellIndex);

}
}
eXcell_myprice.prototype = new eXcell_price;

Regards,
Shraddha

Actually you can have edn and later setNumberFormat to achieve the same effect

grid.setNumberFormat("$ 0,000");

which will allow to edit raw numbers but show them with necessary formatting and prefix ( pro version only )

As for custom excel code, it need to return numeric value without formatting for sorting purposes

this.setValue = function(val) { this.cell.rawValue = val; ... this.getValue = function(val) { return this.cell.rawValue; };