This is a migrated thread and some comments may be shown as answers.

Execute javascript function after RadGrid sort

3 Answers 244 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Emil
Top achievements
Rank 2
Emil asked on 26 Jan 2013, 10:13 AM
I have a JavaScript function called 'ResizeGrid' that resizes the RadGrid.

I want to run it after the user clicks the column header and sorts the grid.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Jan 2013, 05:24 AM
Hi,

Please try the following code snippet to call a javascript function on sorting.

C#:
protected void Radgrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.SortCommandName)
    {
        string openWindowScript = "<script language='javascript'>function f(){ResizeGrid(); Sys.Application.remove_load(f) ;}; Sys.Application.add_load(f)  ;</script>";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "radalert", openWindowScript);
    }
}

Thanks,
Shinu.
0
Emil
Top achievements
Rank 2
answered on 28 Jan 2013, 07:57 AM
Hello Shinu,

It doesn't work!

I've tried to move it to the RadGrid1.SortCommand event and still doesn't work.

Thank you for your reply!
0
Emil
Top achievements
Rank 2
answered on 28 Jan 2013, 11:24 AM
To make it work, I've added this to the RadGrid in aspx:

<ClientSettings>
   <ClientEvents OnGridCreated="ResizeGrid" />
</ClientSettings>
Tags
Grid
Asked by
Emil
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Emil
Top achievements
Rank 2
Share this question
or