RadAjax 回调后执行客户端 Javascript

发布于 2024-08-12 06:07:06 字数 670 浏览 3 评论 0原文

我有一个 Web 表单,它使用 Telerik RadAjaxManager (通过 RadAjaxManager 代理)根据过滤条件更新 RadGrid。当标准发生变化时,我重新绑定网格,但现在我还想使用 JavaScript 调整客户端上网格的大小。当我重新绑定网格时,如何才能执行 JavaScript?页面中已经存在JS代码,只需调用即可。

例如,当我增加 RadGrid 中的行数时,它会恢复到默认高度,远小于其容器的高度,直到我调整大小或重新加载页面,此时网格的大小由下面的代码调整。我希望能够在我的条件以及行数发生变化时执行 resizeChildren()

    function resizeChildren() {
        $("#ctl00_mainContentPlaceHolder_grid_GridData").height($(window).height() - 160);
    }

    $(document).ready(function() {
        resizeChildren();
    });
    $(window).resize(function() {
        resizeChildren();
    });

我知道我可以完全使用客户端代码来完成此操作,但我想知道如何执行客户端代码作为 Ajax 回调响应的一部分。

I have a web form that uses the Telerik RadAjaxManager (via RadAjaxManager proxy) to update a RadGrid based on filter criteria. When the criteria change, I rebind the grid, but now I also want to resize the grid on the client, using JavaScript. How can I cause my JavaScript to be executed when I rebind the grid? The JS code already exists on the page, and just needs to be called.

E.g. When I increase the number of rows in the RadGrid, it reverts to a default height, much less that the height of its container, until I resize or reload the page, when the grid is sized by the code below. I want to be able to execute resizeChildren() when my criteria, and thus the number of rows, changes.

    function resizeChildren() {
        $("#ctl00_mainContentPlaceHolder_grid_GridData").height($(window).height() - 160);
    }

    $(document).ready(function() {
        resizeChildren();
    });
    $(window).resize(function() {
        resizeChildren();
    });

I know I can do this with client side code altogether, but I want to know how to execute client side code as part of the response to an Ajax callback.

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

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

发布评论

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

评论(2

波浪屿的海角声 2024-08-19 06:07:07

我知道这个问题已经得到解答,但我想插话...

如果您在 RadAjaxPanel 内添加 RadScriptBlock,那么每当包含的对象导致 ajax-postback 时就会执行它

I know this has already been answered but I wanted to chime in...

If you add a RadScriptBlock inside of a RadAjaxPanel then it will be executed whenever a contained object causes the ajax-postback

指尖微凉心微凉 2024-08-19 06:07:07

我要做的是使用 RadAjaxManager 的响应脚本集合或 PageRequestManager 的 pageLoaded 处理程序。有关详细信息,请参阅 Telerik 网站上的本文

What I would do is either using the response scripts collection of RadAjaxManager or the pageLoaded handler of the PageRequestManager. See this article on the Telerik site for details.

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