Number formatting in Datatable, if Column-Values are Numeric

Hi,

how can I set a conditional format to datatable-columns?
The data must be formatted, but only if they are numeric.

you can use column’s format method and check value by isFinite

format : function(value){
 if(isFinite(value)){
   return webix.Number.format(value, {
    groupDelimiter:",",
    groupSize:3,
    decimalDelimiter:".",
    decimalSize:2
});
 }else{
return value;
}
}

Do I have to insert this in Column-Definition?

yes
http://docs.webix.com/datatable__columns_configuration.html#dataformats

Thank you! Worked for me in combination with parseFloat:

if(isFinite(parseFloat(value)))
{
return webix.Number.format(parseFloat(value),{
groupDelimiter : “.”,
groupSize:3,
decimalDelimiter:",",
decimalSize:0
});
}
else
{
return value;
}

One case is quiet problematic…

A value like this: ‘1100 - ASDFGH’ is evaluated as numeric, after parseFlaot(). That must be handled as a string.

And a value like this: ‘6000,45’ ist evaluated as string, when NOT using parseFloat()…

So how can I check this conditions?

actually you do not have to use parseFloat with isFinite. in this case first problem will not occur. if you want to deal with comma in string you should use either culture based parser or replace commas with dots