【发布时间】:2016-09-30 07:12:50
【问题描述】:
我创建了一个剑道网格并使用 ajax 调用加载它的数据源。网格正在正确加载并且工作正常。现在我想仅基于一列对网格中的数据进行排序。网格定义如下:
$("#grid").kendoGrid({
scrollable: true,
resizable:true,
filterable: {
extra:false,
operators: {
string:{ contains: "Contains"}
}
},
dataSource: {
transport: {
read: {
url: urlStr + dataPrm,
dataType: "json",
async:true
},
parameterMap: function(data, type) {
if (type == "read") {
return {
$start_rows: data.skip,
$page_size: data.pageSize
}
}
}
},
pageSize: 20,
serverPaging : true,
schema : {
model: {
fields: {
a_id : { type: "string" },
a_percentage: { type: "number" },
emp_last_name: { type: "string" },
emp_first_name : { type: "string" }
}
},
data: function(response) {
return response.GridResult;
},
total: function(response) {
$("#totalRows").text(response.total);
return response.total;
}
},
}
pageable: {
pageSizes: true,
},
columns: [
{ field: "a_id",width:"17%",title: "A ID",headerTemplate: '<span title="A ID" style="font-weight: 300; color:#333">A ID</span>',template:"<a class='link' style='cursor:pointer'>#=a_id#</a>" },
{ field: "emp_last_name",width:"15%",title: "Last Name",template:"<span>#=emp_last_name#</span>",headerTemplate: '<span title="Employee" style="font-weight: 300; color:#333">Last Name</span>'},
{ field: "emp_first_name",width:"15%",title: "First Name",template:"<span>#=emp_first_name#</span>",headerTemplate: '<span title="Employee" style="font-weight: 300; color:#333">First Name</span>'},
{ field: "a_percentage", title: "percentage value",width:"15%",template: "#=getPercentage(a,a_percentage)#" }
]
});
如您所见,我已在其中使用 ajax 调用创建了网格。 当网格加载时,它必须是基于名为“a_percentage”的列的排序形式。 “a_percentage”列的值是使用名为“getPercentage”的方法评估的。 我已经在这个网格中实现了排序逻辑,但它限制用户点击可排序的列,即 a_percentage。 我不想通过单击此列对数据进行排序。 每当加载网格时,它必须根据“a_percentage”列按降序排序。 请帮助我如何实现此功能。
【问题讨论】:
标签: kendo-grid