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

How to rebind more three RadGrid after close the RadWindow

1 Answer 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manish
Top achievements
Rank 2
Manish asked on 01 Nov 2013, 10:59 AM
Hi,

I am getting problem in rebind radgrid on radwindow close because i have to rebind 3 grid on parent page. It is rebinding just last grid which i have mentioned in code.
 
Following code i have used in my code

///------ In radwindow javascript code -------
 function clientClose(arg) {
                getRadWindow().close(arg);
                var oWin = getRadWindow();
                var parentWindow = oWin.BrowserWindow;
                // top.location.href = top.location.href;
                parentWindow.refreshGrid();
            }

/// ---------In parent page javascirpt code -----
        function refreshGrid() {
                var masterTable1 = $find("<%=rgDefinition.ClientID%>").get_masterTableView();
                var masterTable2 = $find("<%=rgDevelopment.ClientID%>").get_masterTableView();
                  var masterTable3 = $find("<%=rgTesting.ClientID%>").get_masterTableView();
               masterTable1.rebind();
               masterTable2.rebind();
               masterTable3.rebind();
            }
      
Problem is that ----   this code rebinding my last grid means masterTable3.rebind(); because it is in the last of code.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 04 Nov 2013, 12:59 PM
Hello Manish,

The functionality you want could not be achieved entirely on client-side. 

One possible solution for your requirement could be to fire a custom command through one of the grids and in the code-behind to rebind the three grids.

Here is how you could fire command from a grid:
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
    <script type="text/javascript">
        function rebindGrids(sender, args) {
            var grid = $find("<%=RadGrid1.ClientID%>");
            grid.get_masterTableView().fireCommand("rebindGrids", "");
        }
    </script>
</telerik:RadScriptBlock>
 
<telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true" OnClientClose="rebindGrids"></telerik:RadWindow>
 
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
    <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCommand="RadGrid1_ItemCommand"></telerik:RadGrid>
    <telerik:RadGrid ID="RadGrid2" runat="server" OnNeedDataSource="RadGrid2_NeedDataSource"></telerik:RadGrid>
    <telerik:RadGrid ID="RadGrid3" runat="server" OnNeedDataSource="RadGrid3_NeedDataSource"></telerik:RadGrid>
</telerik:RadAjaxPanel>

And the code-behind for handling the custom command:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "rebindGrids")
    {
        RadGrid1.Rebind();
        RadGrid2.Rebind();
        RadGrid3.Rebind();
    }
}

Attached you could find a sample page with the above functionality.

Hope that helps.

 

Regards,
Konstantin Dikov
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Manish
Top achievements
Rank 2
Answers by
Konstantin Dikov
Telerik team
Share this question
or