This question is locked. New answers and comments are not allowed.
Daniel Collier
Top achievements
Rank 1
Daniel Collier
asked on 25 May 2010, 10:42 PM
I'd like to pass the Viewdata.Model to the my ajax method called via LoadContentFrom(), but I don't see a way to do that given the routeValues collection available to me. Is this possible or am I missing something?
3 Answers, 1 is accepted
0
Hello Daniel Collier,
Unfortunately the behavior, which you are looking for is not achievable. Behind the scenes LoadContentFrom method generate URL to a concrete Action method, which then is serialized to the client. Once you click the tab, an Ajax request is performed to the server using URL generated by LoadContentFrom method. Hence there is no suitable way to pass Model to the partial view which is loaded via Ajax. Nevertheless you can the required model to the partial view through Action method which returns it.
All the best,
Georgi Krustev
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.
Unfortunately the behavior, which you are looking for is not achievable. Behind the scenes LoadContentFrom method generate URL to a concrete Action method, which then is serialized to the client. Once you click the tab, an Ajax request is performed to the server using URL generated by LoadContentFrom method. Hence there is no suitable way to pass Model to the partial view which is loaded via Ajax. Nevertheless you can the required model to the partial view through Action method which returns it.
All the best,
Georgi Krustev
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.
0
Daniel Collier
Top achievements
Rank 1
answered on 26 May 2010, 11:11 AM
Thanks for the reply. I understood most of what you said. The entire ajax request is encoded in the url, so its hard to send it an entire model object, like you can in a post request. I'm not quite sure I understood that last part though. Are you saying I can generate the model object I want in the controller method called for the Ajax request? That is basically what I'm doing now.
Basically right now we have one giant page that takes a customerId. Through nHibernate it uses that customerId to generate a list of entity A. It then uses values in A to create entity objects B,C,D,E and F. These are all then displayed on the page in a homegrown accordian/panelbar showing B-F. The performance hit of calling A-F in one request is quite severe, and most users only use A and B most of the time anyway. What we'd like to do is make these tabstrips with B as the default tab and call C-F as ajax, but like you said, it doesn't seem really feasible to pass a list of objects encoded in a url. I guess I could take solace in the fact that A should be in the nHibernate cache for the subsequent calls, maybe?
So just to reiterate, my goal is to get some reuse out of list A and not have to make that nhibernate call 6 times. And you're saying this is not really possibly, right?
Thanks for your help.
Dan
0
Hi Daniel,
Excuse for missing some words in the last part of my answer :). You get me absolutely right. It is not possible, at least it is not a good approach, to serialize model as a RouteValues. The Ajax call, which is performed through jQuery is GET request and as you can image there is no much place to put Model data in URL.
The only reasonable solution is to cache some of the data.
Regards,
Georgi Krustev
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.
Excuse for missing some words in the last part of my answer :). You get me absolutely right. It is not possible, at least it is not a good approach, to serialize model as a RouteValues. The Ajax call, which is performed through jQuery is GET request and as you can image there is no much place to put Model data in URL.
The only reasonable solution is to cache some of the data.
Regards,
Georgi Krustev
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.