Skip to content

Example - Grid - MarketCap/LastSale sort as strings instead of numbers  #2

Description

@DanTanzer

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;
}));
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions