开发者

Filtering of Telerik MVC Grid using javascript doesn't work with custom binding

开发者 https://www.devze.com 2023-03-29 04:00 出处:网络
I have a Telerik MVC grid which uses custom binding. Using javascript I store the filter, page and grouping in a cookie, such that when the user reloads the page, the filtering etc. is restored:

I have a Telerik MVC grid which uses custom binding. Using javascript I store the filter, page and grouping in a cookie, such that when the user reloads the page, the filtering etc. is restored:

$(document).ready(function () {
   //restore previously saved filters
    var params = $.deparam($.cookie("MyGridCookie"));
    var grid = $("#MyGrid").data("tGrid");
    var refresh = false;
    if (params开发者_运维技巧.filterBy && params.filterBy != "") { grid.filterBy = params.filterBy; refresh = true; }
    if (params.currentPage && params.currentPage != 1) { grid.currentPage = params.currentPage; refresh = true; }
    if (params.orderBy && params.orderBy != "") { grid.orderBy = params.orderBy; refresh = true; }
    if (refresh) grid.ajaxRequest();
});

I've used the exact same code for grids without custom binding and this works just fine. However, in this particular case, the parameter command.FilterDescriptors is empty. But when I manually input the same filter which is stored in the cookie, the filtering works just fine.

So apparently, when custom binding is enabled, the telerik grid does something different when it comes to filtering compared to a grid without custom binding. Does anyone know how to resolve this issue?


Indeed the problem was with the filters being stored in CompositeFilterDescriptors. Problem solved.


Did you try grid.rebind(); instead of grid.ajaxRequest();

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号