Hi Dimiter,
Thank you for your solution. It work well and i just need to make some little change to fit my case.
One more thing, how can i create a function and call it in sortable compare?
function implStableSort(valA, valB,posA,posB, descending) {
if (valA !== valB) {
return valA === valB ? 0 : (valA > valB) ? 1 : -1;
}
if (descending) {
return posB - posA;
} else {
return posA - posB;
}
}
$("#grid").kendoGrid({
dataSource: dataSource,
sortable: true,
columns:
[
{field: '_position',title: 'Position'},
{field: 'name', title: 'Name'},
{field: 'id', title: 'ID', sortable: {
compare: function(a, b, descending) {
var valA = a.id;
var valB = b.id
if(valA !== valB)
{
return valA === valB ? 0 : (valA > valB) ? 1 : -1;
}
if (descending) {
return b._position - a._position;
} else {
return a._position - b._position;
}
}
}},
{field: 'date', title: 'Date', sortable: {
compare: function(a, b, descending) {
var valA = a.date;
var valB = b.date;
var posA = a._position;
var posB = b._position;
implStableSort(valA,valB,posA,posB,descending);
}
}}
]
});
Thank you