In the grid sample I think it would be better to set up a formatter in the column definition instead of the map function to load the data, this way the number will sort as numbers not strings.
Also since there is nothing going on in the map function you may wish to remove as well.
function moneyFormatter(row, cell, value, columnDef, dataContext) {
if (value == null) {
return value;
} else {
return parseFloat(value).toFixed(2);
}
}
{ id: "LastSale", field: "LastSale", name: "Last Sale", cssClass: "money", minWidth: 100,
formatter: moneyFormatter,
filter: { type: 'number' } },
{ id: "MarketCap", field: "MarketCap", name: "Market Cap", cssClass: "money", minWidth: 150,
formatter: moneyFormatter,
filter: { type: 'mumber' } },
ajaxGet('./companylist.txt', {}).subscribe(function (data) {
itemsSource(JSON.parse(data).map(function (company) {
//
// removed these
//
// money formatter
//company.LastSale = moneyFormatter(company.LastSale);
//company.MarketCap = moneyFormatter(company.MarketCap);
return company;
}));
});
In the grid sample I think it would be better to set up a formatter in the column definition instead of the map function to load the data, this way the number will sort as numbers not strings.
Also since there is nothing going on in the map function you may wish to remove as well.
function moneyFormatter(row, cell, value, columnDef, dataContext) {
if (value == null) {
return value;
} else {
return parseFloat(value).toFixed(2);
}
}
{ id: "LastSale", field: "LastSale", name: "Last Sale", cssClass: "money", minWidth: 100,
formatter: moneyFormatter,
filter: { type: 'number' } },
{ id: "MarketCap", field: "MarketCap", name: "Market Cap", cssClass: "money", minWidth: 150,
formatter: moneyFormatter,
filter: { type: 'mumber' } },
ajaxGet('./companylist.txt', {}).subscribe(function (data) {
itemsSource(JSON.parse(data).map(function (company) {
//
// removed these
//
// money formatter
//company.LastSale = moneyFormatter(company.LastSale);
//company.MarketCap = moneyFormatter(company.MarketCap);
return company;
}));
});