Radgrid doesn't rerender after returning from Model Popup Window.

1 Answer 64 Views
Ajax Grid Window
Sean
Top achievements
Rank 1
Sean asked on 18 Oct 2023, 05:29 PM | edited on 24 Oct 2023, 02:24 PM

Hello.  I have a modal popup RadWindow being used as an edit form. This RadWindow is launched from a row in a RadGrid. Everything works great, except when the user finishes with the RadWindow and it closes, the calling RadGrid successfully does a rebind, but it doesn't visually update on the screen. The auto-refreshing the RadGrid works great for other uses such as deleting a record, or updating a record, but not when the rebind code runs upon returning from the modal RadWindow.  When the radwindow closes, it triggers the RadAjaxManager1_AjaxRequest which does the rebind operation. That runs just fine. The only thing not happening is the rendering of the screen so the user sees the updated data in the radgrid.  

Anyone have any ideas why this would be happening or way to force the re-rendering of the screen/radgrid?

This is the script on the source page:

        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function refreshGrid(arg) {
                    if (!arg) {
                        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                    }
                    else {
                        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
                    }
                }
            </script>
        </telerik:RadCodeBlock>

This gets calls when the popup closes:

    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
        If e.Argument = "Rebind" Then
            rgVehicleConfig.DataSource = Nothing
            rgVehicleConfig.Rebind()
        End If
    End Sub

This is the script on the popup aspx page:

    <script type="text/javascript">
        function CloseAndRebind(args)
        {
            GetRadWindow().BrowserWindow.refreshGrid(args);
            GetRadWindow().close();
            document.getElementById("frmSequencingAreas").submit();
        }

        function Close(args)
        {
            GetRadWindow().close();
        }

        function GetRadWindow()
        {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)

            return oWindow;
        }
    </script>

Finally, this is the code for the final import of the data that closes the RadWindow and returns to the calling page:

    Private Sub rgVehicleConfiguration_ItemCommand(sender As Object, e As GridCommandEventArgs) Handles rgVehicleConfiguration.ItemCommand
        If e.CommandName = "Export" Then
            If ErrorsFound Then
                lblMessage.Text = "Highlighted values are invalid. Please correct and try importing file again.</br>Data cannot be imported until all errors are corrected."
            Else
                ExportData()
                ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind();", True)
                ShowPopup = False
            End If
        End If
    End Sub

Most of this code was lifted from Telerik's own demo and that seems to work just fine here on the Telerik demo site.

Any help would be wonderful.

Thank you.

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 23 Oct 2023, 04:29 PM

Hello Sean,

 

Thank you for writing to us.

This probably happens because the AjaxManager cannot properly update the Grid. I couldn't see your AjaxSettings in the code snippets. Can I kindly ask you to check them and ensure that the RadAjaxManager1 updates the rgVehicleConfiguration Grid control?

Also, another test you can do is to disable AJAX altogether:
https://docs.telerik.com/devtools/aspnet-ajax/knowledge-base/common-get-more-descriptive-errors-by-disabling-ajax

And ensure that the Grid will rebind with a simple rebind() call:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/gridtableview-object/methods/rebind

Feel free to try these solutions and keep me updated on the result.

 

Regards,
Eyup
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Sean
Top achievements
Rank 1
commented on 24 Oct 2023, 02:23 PM

Here is my RadAjaxManager code:

As mentioned above, I can confirm that the call to the above AjaxRequest is working fine and, after the RadGrid rebind runs, I can see that the data in the table in memory has, indeed, refreshed. If I were to do something that rerenders the radgrid, such as selecting another expand group, suddenly the new data appears.

It appears the only thing not happening is an actual rerender of the Radgrid itself when the modal window closes and the rebind occurs.

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgSequencingAreas" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
Eyup
Telerik team
commented on 27 Oct 2023, 08:10 AM

Hi Sean,

Thank you for sharing this. Here are my suggestions:

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rgVehicleConfiguration">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgVehicleConfiguration" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgVehicleConfiguration" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
Feel free to apply this solution and let me know about the result.

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