Execute client Javascript after RadAjax callback

ProfK picture ProfK · Nov 27, 2009 · Viewed 12.7k times · Source

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.

Answer

Matthew picture Matthew · Sep 14, 2010

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