This question is locked. New answers and comments are not allowed.
Hi!
I am implementing an external component to filter the grid control. The functionality will be similair to http://demos.telerik.com/aspnet-mvc/razor/Splitter/NestingComponents but with much more complex filtering options of course.
What is the best/simplest way to update the grid via ajax? I can without any problems replace the entire grid, but i would like to update the values only if at all possible. Any guidance?
Thanks in advance!
/Victor
I am implementing an external component to filter the grid control. The functionality will be similair to http://demos.telerik.com/aspnet-mvc/razor/Splitter/NestingComponents but with much more complex filtering options of course.
What is the best/simplest way to update the grid via ajax? I can without any problems replace the entire grid, but i would like to update the values only if at all possible. Any guidance?
Thanks in advance!
/Victor
7 Answers, 1 is accepted
0
Hi Victor,
Atanas Korchev
the Telerik team
The filter JavaScript method is best suited for this task.
Kind regards,Atanas Korchev
the Telerik team
0
Victor
Top achievements
Rank 1
answered on 25 Mar 2011, 09:26 AM
Hi!
Thanks for the reply, but I think you misunderstood, allow me to clarify. Basically I have a complex filtering component that filters on properties only available server-side. So:
The thing is that I in steps 5 and 6 want to also send the newly generated List<Person> and, using that, update the grid. Is it possible to take advantage of the existing server-side and/or client-side logic to make this happen? I also realize now that I _have_ to do it in some "telerik-native" way, since I also want support for paging/sorting/etc (which means making sure the grid sends the custom filtering data in later requests)
Any ideas on how to solve this will be greatly appreciated.
/Victor
Thanks for the reply, but I think you misunderstood, allow me to clarify. Basically I have a complex filtering component that filters on properties only available server-side. So:
- I render the grid based on a full List<Person> in the right pane and a custom filtering component in the left
- I select some filter properties
- An ajax call is sent to a custom action method
- In that action method I generate a new List<Person> based on the new filtering criteria
- I send some feedback to the filtering component in a Json reply
- I update the filtering component
The thing is that I in steps 5 and 6 want to also send the newly generated List<Person> and, using that, update the grid. Is it possible to take advantage of the existing server-side and/or client-side logic to make this happen? I also realize now that I _have_ to do it in some "telerik-native" way, since I also want support for paging/sorting/etc (which means making sure the grid sends the custom filtering data in later requests)
Any ideas on how to solve this will be greatly appreciated.
/Victor
0
Hi Victor,
Atanas Korchev
the Telerik team
You can perhaps bind the grid to the filtered datasource. The grid will do the paging and sorting for you. The other option is to try and use the grid server filtering API instead. In both cases however you will need to update the whole grid through Ajax. The only option not to update the whole grid is to use the filter JavaScript method.
Atanas Korchev
the Telerik team
0
Victor
Top achievements
Rank 1
answered on 25 Mar 2011, 10:40 AM
Ok thanks, I certainly realize the problem. I guess what I really need is to rebind or recreate fully the grid with some filtering attributes as "constant arguments" to the _Select function. However I cannot see any way to change the binding urls after initialization?
One option seems to be to override the OnDataBinding event and (looking at the twitter example) setting the url variable to one respecting the custom filtering options. However I cant see how to get (and respect) internal filtering values, sorting etc - is that possible? When all that is done, all that seems that it needs to be done is either calling the ajaxRequest method (which is also used in sorts etc) or to call the dataBind method (to make it possible to get all data in one request).
Would this work?
/Victor
One option seems to be to override the OnDataBinding event and (looking at the twitter example) setting the url variable to one respecting the custom filtering options. However I cant see how to get (and respect) internal filtering values, sorting etc - is that possible? When all that is done, all that seems that it needs to be done is either calling the ajaxRequest method (which is also used in sorts etc) or to call the dataBind method (to make it possible to get all data in one request).
Would this work?
/Victor
0
Accepted
Hello Victor,
Atanas Korchev
the Telerik team
You can perhaps send custom values through the OnDataBinding event:
function onDataBinding(e) {
e.data = { custom: "value" };
}
if you call the ajaxRequest method the grid will be refreshed using the current state information (paging, sorting etc). The rebind method will reset the grid (first page, no sort expression).
Atanas Korchev
the Telerik team
0
Victor
Top achievements
Rank 1
answered on 04 Apr 2011, 08:32 AM
Hi again!
Manually binding data to the grid using
works very well (jsonData is the ajax response and jsonData.gridData is an onobject containing the grid data (serialized from a list of the class the grid is initially bound to. Of course no grid functions (sort/page/...) works, but that's expected.
Next step is to employ the OnDataBinding event in some way. How do I subscribe to that event i js code? That is - I only want to subscribe to it when the filtering component is fully initialized, and I also want to do it from within that code, is that possible?
/Victor
Manually binding data to the grid using
grid.dataBind(jsonData.gridData);Next step is to employ the OnDataBinding event in some way. How do I subscribe to that event i js code? That is - I only want to subscribe to it when the filtering component is fully initialized, and I also want to do it from within that code, is that possible?
/Victor
0
Accepted
Hello Victor,
Regards,
Atanas Korchev
the Telerik team
This should work:
$("#Grid").bind("dataBinding", function() { alert("OnDataBinding") });
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items