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

Targeting controls with ajaxRequest

5 Answers 76 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Murray MacBeath
Top achievements
Rank 1
Murray MacBeath asked on 15 Jan 2010, 04:14 PM
Hi.  Please consider the following scenario:
  • I have several RadGrids on a page.
  • I am using the RadAjaxManager.ajaxRequest method from Javascript.
  • In my code-behind, I respond to the AjaxRequest event, and then.....
  • .... depending on the Argument, I wish to update one of the RadGrids.

In order to ensure my AjaxRequest causes an update on the page, I understand that I have to add the AjaxManager itself as the initiating control, and then add the RadGrids as the updated controls.  However, I don't want to update them all every time I raise the AjaxRequest event.  I only want to update the grid that is affected.

Any suggestions?
Thanks,
Murray

5 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 19 Jan 2010, 08:39 AM
Hello Murray,

Instead of using the manager as AJAX initiator I would suggest you to AJAX-ify any of the grids and trigger a AJAX call through the manager's ajaxRequestWithTarget() method.

I have attached a small sample project demonstrating this approach. Clicking any of the buttons will force an update to the CurrentPageIndex property of the relevant grid.

I hope this helps,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Murray MacBeath
Top achievements
Rank 1
answered on 29 Jan 2010, 06:30 PM
Hi Martin,

Thanks for your very helpful response.  That's exactly what I need, and it has pointed me in the right direction.

For the sake of anyone else viewing this thread....  Note that the sample website isn't quite complete.  You will also need to provide an eventArgument with the ajaxRequestWithTarget method.  Otherwise, you will be unable to differentiate between ajax requests raised by the grid itself and the ajax requests raised by your javascript.  For an example of this, change the "Page Size" in the sample website, and you'll see that without an event argument, the grid not only changes its page size, but also advances by one page (both events get handled).

Thanks again, Martin.
Murray

0
Murray MacBeath
Top achievements
Rank 1
answered on 29 Jan 2010, 08:44 PM
Oh... and note also that the ajaxRequestWithTarget requires use of the control's UniqueID, not the ClientID (as in the sample website).
0
Accepted
Martin
Telerik team
answered on 01 Feb 2010, 01:56 PM
Hello Murray,

Indeed you are correct about both the required modifications. I have attached a new version of the sample project that reflects these changes. In addition It also demonstrates another approach to achieves the same functionality. To be more specific - you can directly AJAX-ify any of the buttons to update the relevant grid. The drawback is the double number of AJAX settings that are needed.

Regards,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Murray MacBeath
Top achievements
Rank 1
answered on 01 Feb 2010, 03:37 PM
Hi Martin,

Thanks again.  Actually, it was specifically the use of ajaxRequestWithTarget that I was looking for.  The situation I stated was a much simplified version of what I really needed (in which the use of buttons is not an option).  To make a long story short, I am triggering ajax requests on one web page using javascript from another web page.

Murray

Tags
Ajax
Asked by
Murray MacBeath
Top achievements
Rank 1
Answers by
Martin
Telerik team
Murray MacBeath
Top achievements
Rank 1
Share this question
or