RadAjaxManager AJAXRequest with 2 RadGrids

4 posts, 0 answers
  1. GP
    GP avatar
    58 posts
    Member since:
    Oct 2009

    Posted 14 Dec 2011 Link to this post

    Good morning.  I have 2 grids that use a RadWindow to do their Insert/Updates.  I have them returning and updating properly.  The only problem is that I noticed is that when I update one grid, both grids are refreshed by the ajax manager.  I'd like to see only one grid refresh at a time.

    Below is the AJAX setting to allow the rebinds to happen.
    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"/>
            <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1"/>
        </UpdatedControls>
    </telerik:AjaxSetting>

    Below is the call to refresh the grids based on type.  I'm mostly sending you this so that you can see the AJAX call.
    function refreshGrid(args, type) {
        if (type == "A") {
            if (args == 1) {
                radalert("Action Updated");
            }
            else {
                radalert("Action Added");
            }
            $find("<%= RadAjaxManager.GetCurrent(me).ClientID %>").ajaxRequest("RebindActions");
        }
        else {
            if (args == 1) {
                radalert("Record Updated");
            }
            else {
                radalert("Record Added");
            }
            $find("<%= RadAjaxManager.GetCurrent(me).ClientID %>").ajaxRequest("RebindRecords");
        }
         
    }


    Is there a way to only refresh one of these grids at a time?

    Thanks!
  2. Vasil
    Admin
    Vasil avatar
    1635 posts

    Posted 16 Dec 2011 Link to this post

    Hello,

    Use such settings that each grid to update only itself.
    <telerik:AjaxSetting AjaxControlID="RadGrid1">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"/>
        </UpdatedControls>
    </telerik:AjaxSetting>
    <telerik:AjaxSetting AjaxControlID="RadGrid2">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1"/>
        </UpdatedControls>
    </telerik:AjaxSetting>

    Then when you need to perform Ajax call, just fire custom command using .fireCommand() client method of the MasterTableView of one of the grids.

    I hope this help.

    Regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. GP
    GP avatar
    58 posts
    Member since:
    Oct 2009

    Posted 18 Dec 2011 Link to this post

    This only works if data is already loaded into the Radgrid.  If initially, no records return, and the grid has the message "No Data to display", then the mastertable is not there to rebind.
  4. GP
    GP avatar
    58 posts
    Member since:
    Oct 2009

    Posted 18 Dec 2011 Link to this post

    Got it.  You put me on the right trail, so thank you.  Here was the solution that worked for me.

    var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
    masterTable.rebind();
Back to Top