Custom sorting algorithm Kendo UI Grid
Kendo UI Grid
by Pankaj Sapkal
HTML
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.default.min.css">
<script src="http://cdn.kendostatic.com/2013.2.716/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2013.2.716/js/kendo.all.min.js"></script>
<div id="grid"></div>
CSS
#grid {
width : 490px;
}
.ob-hidden {
display: none;
visibility: hidden;
}
JavaScript
var ds = {
data : [
{ id : 1, name : "john" },
{ id : 2, name : "jane" },
{ id : 3, name : "Jane" },
{ id : 4, name : "jack" },
{ id : 5, name : "jane" },
{ id : 6, name : "janette" },
{ id : 7, name : "John" }
],
pageSize: 10,
schema : {
model: {
fields: {
id : { type: 'number' },
name : { type: 'string' }
}
}
}
};
$("#grid").kendoGrid({
dataSource: ds,
sortable : true,
columns : [
{ field: "id", title: "id" },
{
field: "name",
title: "Name",
sortable: {
compare: function (a, b) {
return a.name === b.name ? 0 : (a.name > b.name) ? 1 : -1;
}
}
}
]
});