I am using Kendo-Grid which is having a column has values of both number & string (NA). Any idea how to sort them?
You can sort them using a custom compare function. Here is some sample code which will put items with 'N/A' on top:
$("#grid").kendoGrid({
dataSource: [
{ price: 1 },
{ price: "N/A" },
{ price: 20 },
{ price: 2 }
],
sortable: true,
columns: [
{
field: "price",
sortable: {
compare: function(a, b) {
var x = a.price;
var y = b.price;
if (x == 'N/A') {
x = 0;
}
if (y == 'N/A') {
y = 0;
}
return x - y;
}
}
}
]
});
Here is a live demo: http://jsbin.com/urUXOCa/1/edit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With