This question is locked. New answers and comments are not allowed.
Hi,
I want to persist some filter expressions so that they can be reused in a dynamic way. But I have not been able to set the filtering expression dynamically. In my testing I thought that all I had to do was set the filterBy property of the grid to an appropriate expression and then rebind the grid. I have not had any luck doing this. Here is what I have tried.
The grid is using AJAX databinding.
I have a column named major and it has some values which begin with the characters MBA-
In the onDataBinding function:
I want to persist some filter expressions so that they can be reused in a dynamic way. But I have not been able to set the filtering expression dynamically. In my testing I thought that all I had to do was set the filterBy property of the grid to an appropriate expression and then rebind the grid. I have not had any luck doing this. Here is what I have tried.
The grid is using AJAX databinding.
I have a column named major and it has some values which begin with the characters MBA-
In the onDataBinding function:
var filterby = "major~startswith~'MBA-'"; var grid = $('#TestForFilteringGrid').data('tGrid');grid.filterBy = filterby;7 Answers, 1 is accepted
0
Joshua
Top achievements
Rank 1
answered on 05 Jan 2012, 10:08 PM
Have you found a solution to this? I'm having the exact same issue and there seems to be zero help on this subject!
0
Hi Richard,
Greetings,
Daniel
the Telerik team
To filer the data dynamically you should use the Grid's filter method.
Greetings,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Joshua
Top achievements
Rank 1
answered on 06 Jan 2012, 03:46 PM
This still does not work. What is the appropriate client side event to place this in? OnLoad?
My code is as follows:
The alert shows the actual filter expression (which is formatted properly), but the filter never gets applied.
My code is as follows:
The alert shows the actual filter expression (which is formatted properly), but the filter never gets applied.
function onLoad(e) { var grid = $('#ExpenditureSummaryGridPSF').data("tGrid"); if ("@ViewBag.FirstLoad" != "yes") { grid.filter = unescape("@ViewBag.FilterBy"); alert(grid.filterBy); } }0
Hello,
If you want to apply initial filtering I suggest checking the Filtering demo.
The client-side filter method can be used at any time. For example:
All the best,
Daniel
the Telerik team
If you want to apply initial filtering I suggest checking the Filtering demo.
The client-side filter method can be used at any time. For example:
var grid = $("#Grid").data("tGrid");//Display all records whose OrderID property is equal to 10248grid.filter("OrderID~eq~10248");All the best,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Joshua
Top achievements
Rank 1
answered on 06 Jan 2012, 06:26 PM
Thanks for the reply Daniel. What I have is two pages with virtually identical grids (save for some content) and I want the filters, sort, and groups to carry over back and forth between the pages. I have the onLoad event of the grids set and in the onLoad function am using the code above. the grid.filter just does not appear to do anything. Any ideas or tips that might be stopping this?
Thanks!
Thanks!
0
Joshua
Top achievements
Rank 1
answered on 06 Jan 2012, 06:52 PM
I have verified now that after the grid.filter() is set, I alert(grid.filterBy) and the filter is properly set, however the grid is not changing to reflect the filter
0
Joshua
Top achievements
Rank 1
answered on 06 Jan 2012, 08:57 PM
Here is the best answer (maybe the only answer) I have found yet. It simply uses the GridRouteValues to ensure the grid state is preserved.
http://www.telerik.com/community/code-library/aspnet-mvc/grid/preserve-grid-state-between-pages.aspx
http://www.telerik.com/community/code-library/aspnet-mvc/grid/preserve-grid-state-between-pages.aspx