asp.netajaxtelerikradajaxmanager

Execute client Javascript after RadAjax callback


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.


Solution

  • 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.