我们正在将一个应用程序从 Telerik MVC 转换为 Kendo UI。我们的网格上有 jQuery 代码来捕获当前的 orderBy 和 filterBy 参数,这样我们就可以将它们传回我们的 Controller 。然后 Controller 使用这些参数创建 Excel 下载。
但是 orderBy 和 filterBy 现在在 Kendo 中是未定义的。我如何检索这些值?
function onDataBound() {
$('a.lnkDeal').each(function () {
this.href = this.href.replace(/&/g, "%26");
});
var grid = $("#Deals").data('kendoGrid');
// Get the export link as jQuery object
var $exportLink = $('#ExportToExcel');
// Get its 'href' attribute - the URL where it would navigate to
var href = $exportLink.attr('href');
// Update the 'orderBy' parameter with the grids' current sort state
href = href.replace(/orderBy=([^&]*)/, 'orderBy=' + (grid.orderBy || '~'));
// Update the 'filter' parameter with the grids' current filtering state
//href = href.replace(/filter=(.*)/, 'filter=' + (grid.filterBy || '~'));
// Update the 'href' attribute. Replace all ' with | to avoid security issue
href = href.replace(/'/g, "|");
$exportLink.attr('href', href);
}
最佳答案
检查 filter
定义为对象和 sort
在 DataSource 中过滤和排序结果。
将这两个选项与serverSorting
结合起来和 serverFiltering
用于向服务器发送排序和过滤参数。
关于javascript - 从 Telerik 切换到 Kendo UI 缺少 orderBy 和 filter By,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19361662/