Telerik AJAX 和更新 RadGrid

发布于 2024-10-07 05:11:31 字数 1061 浏览 3 评论 0原文

我有一个 ASP.NET 页面,显示带有数据的 RadGrid。它显示成员所属“组”的列表。它显示组名称,以及编辑和删除按钮。 (页面上还有一个单独的“添加”按钮)。相当标准的东西。

当您单击按钮编辑组时,我们会在 RadWindow 中启动一个新表单。这是一个单独的 ASPX 页面,显示在 RadWindow 中。您可以编辑群组名称,并添加/删除成员。

当您关闭窗口时,您的更改将保留到数据库中,然后通过 JavaScript 启动 AJAX 调用。它真正做的就是重新设置网格的数据源(因此我们拾取刚刚保存到数据库的更改)并调用 Grid.ReBind()。

我遇到的问题是,虽然一切似乎都在执行,但在刷新页面之前,更改不会显示在网格上。这是因为(我相信)即使我们更改了网格数据源,也不会发生回发,因此不会显示任何新内容。

我能够通过调用一点 JavaScript 魔法来强制页面刷新来“修复”这个问题,这确实有效,但是整个页面都会刷新,而且看起来很丑。

我尝试像这样将 RadWindow 添加到 AjaxManagerProxy 中,希望它能够 AJAX 化网格刷新,但事实并非如此。

<telerik:RadAjaxManagerProxy ID="RadProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadWindowManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="GridGroups" />                                    
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>

那么...问题是,如何强制网格以 AJAX 方式刷新?不强制刷新整个页面?

I have an ASP.NET page that displays a RadGrid with data. It displays a list of "groups" that members belong to. It shows the group name, and also an Edit and a Delete button. (There is also a seperate Add button on the page). Pretty standard stuff.

When you click a button to edit a group, we launch a new form in a RadWindow. This is a seperate ASPX page that shows up in the RadWindow. You can edit the name of the group, and add/remove members.

When you close the window, your changes are persisted to the database, and then an AJAX call is initiated via JavaScript. All it really does is re-set the DataSource of the grid (so we pickup the changes that we just saved to the database) and also calls a Grid.ReBind().

The problem I'm having is that, while everything appears to be executing, the changes don't appear on the grid until you refresh the page. This is because (I believe) that even though we changed the Grid DataSource, no postback occurs, and so, nothing new is displayed.

I was able to "fix" this by calling a little JavaScript magic to force a page refresh, and this works, however the entire page refreshes, and that looks ugly.

I tried adding the RadWindow to the AjaxManagerProxy like this, in hopes that it would AJAXify the grid refresh, but that's doesn't do it.

<telerik:RadAjaxManagerProxy ID="RadProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadWindowManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="GridGroups" />                                    
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>

SO... the question is, how do I force the grid to refresh in an AJAX way? Without forcing an entire page refresh?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野心澎湃 2024-10-14 05:11:31

Todd, isn't this live demo do exactly what you are asking for using ajax request on popup close? Take a look and let me know.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文