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

Grid in AJAX partial view

9 Answers 199 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.
Mark Liu
Top achievements
Rank 1
Mark Liu asked on 25 Mar 2010, 11:00 PM
Hi everyone,

I have a scenario where I input search queries in a AJAX form and display the result in another AJAX partial view using the MVC Grid.

My problem is the new grid rendered by the AJAX partial view does not have any JavaScript bound to it. I suspect the grid is initialized during document onload, therefore my AJAX update is not 'initializing it'.

Is there a rebind or initialize function for the grid that I can call in my AJAX Form?

Regards,
Mark Liu

9 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 26 Mar 2010, 09:13 AM
Hello Mark Liu,

I recommend you check the loading components with ajax help topic. It shows how to initialize the Telerik UI components.

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
Stepney
Top achievements
Rank 1
answered on 10 Apr 2010, 05:55 PM
I have run into this problem too.

I have followed the instructions that have been linked to, but still it does not work properly.

I have a partial view that is loaded dynamically. However, the AJAX binding does not work. When the sort or paging operations are selected the control loads on it's own.

The same partial view loaded using the RenderAction function on the same page works perfectly.

I have monitored the events in both cases and for the second case they fire as expected. However, in the former nothing happens.

Data that is supplied via the view model is loaded in both cases, but not the ajax data.

Anyone with ideas on what I may have done wrong?

Does someone have a fully working example?
0
IQworks
Top achievements
Rank 1
answered on 10 Apr 2010, 07:59 PM

Hi Stepney, 
    
    This code library project has a working example of ajax binding using a grid with paging, etc.

    http://www.telerik.com/community/code-library/aspnet-mvc/grid.aspx 
   
thanks

0
Stepney
Top achievements
Rank 1
answered on 10 Apr 2010, 08:42 PM
Hi IQWorks

Is that the Toottips project you are refereing to?

I have ajax binding working for a grid on a page and I have ajax binding working for a grid on a partialview; both work a treat.

What I cannot get working is when I load the very same partial view dynamically using the .load('<% url.action ....... method as described in the documentation.

Has anyone actually got that to work fully?
0
IQworks
Top achievements
Rank 1
answered on 10 Apr 2010, 11:16 PM
Hi Stepney, 
     I didnt understand what you needed there. it wasnt the tooltips I was pointing you to, it was the grid funtionality that the tooltip project itself uses. But I dont use Url.action there. 
    Others might get a better idea of what you mean if you post a code snippet ?
     Sorry to be of no help here.  
 good luck !            
    
0
Stepney
Top achievements
Rank 1
answered on 11 Apr 2010, 11:42 AM
I've cracked it !!!! Well, sort of.

The example code does work. What I had that broke it was the namespaces of my project. I have (had) another level between controllers and my xxxxController class. Once I removed that, it worked.

I have found this problem elsewhere. This library is very unforgiving of variations in the use of namespaces.

Now I have a problem with passing parameters from javascript into Url.Action :(
0
IQworks
Top achievements
Rank 1
answered on 11 Apr 2010, 01:08 PM

HI Stepney, 
  
      Thats great! 

       I will certainly watch my namespaces. Really frustrating to have your code not working because of something not directly in the spot thats breaking.
      OK, I guess my question would be, how you are using the Url.Action() once you pass it the parameters?
     

0
Mark Liu
Top achievements
Rank 1
answered on 12 Apr 2010, 02:31 AM
Hi Atanas Korchev,

Thanks for the help, the example in the documentation is most enlightening.

Just a quick question. In the example for 'Partial Views via the built-in ASP.NET MVC Ajax support', it said:
// use jQuery to update the placeholder. It will execute any JavaScript statements 
$(placeholder).htmll(html); 
 

Is that a typo? should it be "$(placeholder).html(html)"?

Regards,
Mark Liu
0
Atanas Korchev
Telerik team
answered on 12 Apr 2010, 07:21 AM
Hello Mark Liu,

Yes it is a typo. We have fixed it but the online documentation is not yet uploaded.

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.
Tags
Grid
Asked by
Mark Liu
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Stepney
Top achievements
Rank 1
IQworks
Top achievements
Rank 1
Mark Liu
Top achievements
Rank 1
Share this question
or