This is a migrated thread and some comments may be shown as answers.

Returning grid in PartialView from Action

7 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andy McShane
Top achievements
Rank 1
Andy McShane asked on 30 Apr 2010, 02:00 PM
Hi, I have seen similar topics about this but not one that fully answers my question (or maybe I dont understand?). I have an ajax form on my page. This has 2 dropdown lists on it. When the first dropdown list is changed and ajax call is made to populate the second dropdown list. When the select dropdown list changes then the ajax form is posted to an action and the result of that action returns a partialview that contains a grid. The obvious problem that I have here is that none of the js code is bound to the grid. I have tried a couple of different things such as manaually registering the scripts at the end of the partial view but to no avail. Any idea what I am doing wrong here or if there is a better solution to do what I am trying to do? Thanks.

7 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 30 Apr 2010, 02:09 PM
Hello Andy McShane,

This help topic should help you.

Regards,
Atanas Korchev
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
Andy McShane
Top achievements
Rank 1
answered on 30 Apr 2010, 02:15 PM
Thanks. This refers to an Ajax.ActionLink that a user has to click, how would this work with a form post? For example I need to make the ajax call and load my partial view but also pass the parameters from 3 of the fields on my form that specify what data to load?
0
Accepted
Atanas Korchev
Telerik team
answered on 30 Apr 2010, 02:18 PM
Hello Andy McShane,

Please follow the whole article. It explains what needs to be done in order to execute the JavaScript initialization code of the components.

All the best,
Atanas Korchev
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
Andy McShane
Top achievements
Rank 1
answered on 30 Apr 2010, 02:28 PM
Excellent, thanks. One of those Friday afternoon rushes, should always read the whole set of instructions!!!
0
Andy McShane
Top achievements
Rank 1
answered on 30 Apr 2010, 02:39 PM
I am still a little stuck on how I pass parameters in my loadPartialView call i.e.

I am trying to it like this
    function loadPartialView(context) { 
        var c = $("#CustomerId").val(); 
        var p = $("#providerId").val(); 
        var s = $("#supportWorkerId").val(); 
        //Populate the contents of the placeholder with the result returned by the action method HomeController.PartialGrid 
       $('#serviceUserArea').load('<%= Url.Action("ServiceUsers", "ServiceUser", new{ ccustomerId = c , pproviderId = p, ssupportWorkerId = s}) %>'); 
    } 

The problem is this doesn't work as the I get an error stating that the variables c,p,s do not exist as a compilation error because obviously these values have to come from the client side, any pointers?
0
Atanas Korchev
Telerik team
answered on 30 Apr 2010, 03:09 PM
Hi Andy McShane,

This question is not related in any way with Telerik Grid for ASP.NET MVC.

You cannot mix client and server-side code like this. What could possibly work is hardcoding the URL of the action and using string concatenation to append the arguments. Something like this:

var url = "<%= Url.Action("Action", "Controller" %>" + "?argument1=" + value1 + "argument2=" + value2;

Regards,
Atanas Korchev
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
Andy McShane
Top achievements
Rank 1
answered on 30 Apr 2010, 03:12 PM
Sorry, I realised as soon as I posted it that it was a stupid question, I should have known better. I have found the solution I required, just as you have shown, Sorry for wasting your time!
Tags
Grid
Asked by
Andy McShane
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Andy McShane
Top achievements
Rank 1
Share this question
or