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

How to refresh parent page grid when close radwindow?

4 Answers 217 Views
Window
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 06 Aug 2013, 12:31 AM

In the parent page, it had a preview button to prompt a radwindow.

How can I refresh the grid in parent page when user click the Close [X] button of the radwindow.

The radwindow generate in code behind:


Protected Sub rtbMenu_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles rtbMenu.ButtonClick
    If e.Item.Value = "Preview" Then
        Dim url = "~/TrainingAdmin/SIMPER_view.aspx?SIMPER_ID=0&UserID=" & Request.QueryString("UserID") & "&From=" & RadDatePicker_ValidFrom.SelectedDate & "&To=" & RadDatePicker_ValidTill.SelectedDate
 
        Dim windowManager As New RadWindowManager()
        Dim window1 As New RadWindow()
        ' Set the window properties  
        window1.NavigateUrl = url
        window1.ID = "RadWindow1"
        window1.Height = 750
        window1.Width = 740
        window1.Top = 140
        window1.Left = 250
 
        window1.AutoSize = False
        window1.VisibleTitlebar = True
        window1.VisibleStatusbar = False
        window1.VisibleOnPageLoad = True           
 
        ' Set this property to True for showing window from code  
        windowManager.Windows.Add(window1)
        Me.Form.Controls.Add(window1)
 
    ElseIf e.Item.Value = "Refresh" Then
        Response.Redirect("~/TrainingAdmin/SIMPER_details.aspx?userID=" & Request.QueryString("UserID"))
 
    End If
End Sub

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 06 Aug 2013, 09:01 AM
Hi Joe,

You can attach an OnClientClose client event for your RadWindow from C# code and in the OnClientClose event you can rebind the RadGrid as shown below.

C#:
window1.AutoSize = false;
window1.VisibleTitlebar = true;
window1.VisibleStatusbar = false;
window1.VisibleOnPageLoad = true;
window1.OnClientClose = "OnClientClose";

JavaScript:
<script type="text/javascript">
    function OnClientClose(sender, args) {
        var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
        masterTable.rebind();
    }
</script>

Thanks,
Princy.
0
Joe
Top achievements
Rank 1
answered on 06 Aug 2013, 09:09 AM
Great. the code works.
Thanks a lot
0
Ronald
Top achievements
Rank 1
answered on 31 May 2018, 06:04 PM

What if a RadGrid is not using the NeedDataSource event, but instead the data source is being set in a RadTabStrip TabClick event where I bind the datasource to a List<> of custom objects.

Does rebinding the Master Table work in that scenario conform to your example here?

 

0
Marin Bratanov
Telerik team
answered on 01 Jun 2018, 11:25 AM
Hello Ronald,

With such simple data binding it is likely that a lot of the complex features (like sorting, grouping, filtering and so on) will not function. Thus, I recommend that you move towards the NeedDataSource data binding or using a declarative data source (you can set the grid's Visible property to false to prevent it from data binding if you don't want it to): https://www.telerik.com/support/kb/aspnet-ajax/grid/details/how-to-bind-radgrid-properly-on-server-side.

If you want to keep using such simple data binding, I'd suggest you invoke a postback (e.g., click a hidden button programmatically) and provide the new data source to the grid. The .rebind() method may not work as expected in such a case because the grid cannot know what it;s data source is - it is not a declarative data source it can ask to fetch data, nor is its NeedDataSource event hooked, it expects the developer to provide data.


Regards,
Marin Bratanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Window
Asked by
Joe
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Joe
Top achievements
Rank 1
Ronald
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or