Targeting controls with ajaxRequest

6 posts, 1 answers
  1. Murray MacBeath
    Murray MacBeath avatar
    4 posts
    Member since:
    Jul 2009

    Posted 15 Jan 2010 Link to this post

    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

  2. Martin
    Admin
    Martin avatar
    833 posts

    Posted 19 Jan 2010 Link to this post

    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.
  3. Murray MacBeath
    Murray MacBeath avatar
    4 posts
    Member since:
    Jul 2009

    Posted 29 Jan 2010 Link to this post

    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

  4. Murray MacBeath
    Murray MacBeath avatar
    4 posts
    Member since:
    Jul 2009

    Posted 29 Jan 2010 Link to this post

    Oh... and note also that the ajaxRequestWithTarget requires use of the control's UniqueID, not the ClientID (as in the sample website).
  5. Answer
    Martin
    Admin
    Martin avatar
    833 posts

    Posted 01 Feb 2010 Link to this post

    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.
  6. Murray MacBeath
    Murray MacBeath avatar
    4 posts
    Member since:
    Jul 2009

    Posted 01 Feb 2010 Link to this post

    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

Back to Top