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

cannot refresh 2 radgrids on same page

1 Answer 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 22 Oct 2014, 02:56 PM
hi,

I have a project with a page that contains 2 radgrids.
in code behind I open a radwindow that does an update on a row in one grid, and changes the status, so that it appears in the other grid.

this is the code for opening the window


RadWindow ConfirmWindow = new RadWindow();
<
br>ConfirmWindow.NavigateUrl = "HolidayApproveDecline.aspx?Type=" + ((Byte)Type).ToString() + "&IDs=" + IDBuilder.ToString();<br>ConfirmWindow.Width = 450;
<
br>            ConfirmWindow.Height = 430;
<
br>            ConfirmWindow.ID = "wndUserAddHoliday";
<
br>            ConfirmWindow.VisibleOnPageLoad = true;
<
br>            ConfirmWindow.OnClientClose = "RefreshGrid";
<
br>            ConfirmWindow.VisibleStatusbar = false;
<
br>            ConfirmWindow.IconUrl = "../Images/address_book.png";
<
br>            ConfirmWindow.Title = "Bevestigen";
<br>            WindowBehaviors Behaviors = new WindowBehaviors();
<
br>            Behaviors |= WindowBehaviors.Close;
<
br>            ConfirmWindow.Behaviors = Behaviors;<br>
<
br>            ConfirmWindow.Modal = true;<br>            RadWindowManager MasterWindowManager = (RadWindowManager)this.Master.FindControl("MasterWindowManager");<br>            MasterWindowManager.Windows.Add(ConfirmWindow);


Now, upon returning he fires the clientside Refresh function which contains following code:

  <telerik:RadCodeBlock ID="Block2" runat="server">
        <script type="text/javascript">
            function RefreshGrid() {

                var grdGeneralOverview = $find("<%= grdGeneralOverview.ClientID %>").get_masterTableView();
                grdGeneralOverview.rebind();

                var grdApproveDecline = $find("<%= grdApproveDecline.ClientID %>").get_masterTableView();
                grdApproveDecline.rebind();
      </script>
    </telerik:RadCodeBlock>

The OnNeedDatasource functions for both grids in code behind are fired, and the datasources contain the updated data for both grids.

However, and this is the catch, on the screen only the second grid is updated (grdApproveDecline 
)
if I switch the 2 rebinds around, the other gets updated on screen.

Does anyone know why this happens?




1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 27 Oct 2014, 11:29 AM
Hi Steven,

Please note that the rebind() method raises a postback to the server in order to active the command. Since it is not possible to call multiple postback operations simultaneously, you will need to Rebind() the grids on server-side.

To achieve that, you can use the fireCommand method of the first grid and handle its ItemCommand event handler on the code-behind. There you can check for the appropriate command name and Rebind() both of the grids:
http://www.telerik.com/help/aspnet-ajax/grid-gridtableview-firecommand.html

Alternatively, you can use RadAjaxManager and its ajaxRequest method:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=window

Hope this helps.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Steven
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or