只是想列出一个示例代码来帮助其他正在寻找解决方法的人在使用 Kendo 数据源时执行不区分大小写的排序。
var homogeneous = new kendo.data.HierarchicalDataSource({
data: [{
"id":"1237",
"text":"b",
"encoded":false,
"items":[{
"id":"234",
"text":"b1",
"encoded":false,
"items":[{
"id":"456",
"text":"se",
"encoded":false,
"items":[{
"id":"567",
"text":"BB",
"encoded":false
}]
}]
}]
}, {
id: 1,
// lowercase foo should be after 'text:b' in case-insensitive sort
text: "foo"
}],
schema: {
parse: function(data) {
for (var i = 0; i < data.length; i++) {
data[i].lowerText = data[i].text.toLowerCase();
}
return data;
},
model: {
id: "id",
children: "items"
}
},
sort: { field: "lowerText", dir: "asc" }
});
$("#tree").kendoTreeView({
dataSource: homogeneous
});