Execute client Javascript after RadAjax callback
Asked Answered
H

2

7

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.

Hypsometry answered 27/11, 2009 at 13:21 Comment(1)
There is now code and more explanation.Hypsometry
F
3

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.

Fusspot answered 27/11, 2009 at 16:51 Comment(0)
B
4

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

Breeks answered 13/9, 2010 at 23:38 Comment(0)
F
3

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.

Fusspot answered 27/11, 2009 at 16:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.