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

Row collapses upon edit

1 Answer 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Justin Lee
Top achievements
Rank 1
Justin Lee asked on 05 Aug 2010, 08:37 PM
I have a hierarchical RadGrid that is editable.  If you edit a row that is expanded, the row collapses once in edit mode.  Once its in edit mode, you can expand it again and it remains in edit mode. This can be seen in the Telerik demos (http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/threelevel/defaultcs.aspx) so I'm guessing this is the way it was designed, and is not a bug.  But is there a way I can prevent a row from collapsing when it enters edit mode?

Thanks,
Justin

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 06 Aug 2010, 07:36 AM
Helo Justin,

You can customize the behaviour by saving the editform index in global variable and setting the Expanded property back to True (if it was expanded before). Please feel free to change  the logic based on your requirement.

code:
public int check = -1;
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.EditCommandName)
    {
        if (e.Item.Expanded)
        {
            e.Item.Expanded = true;
            check = e.Item.ItemIndex;
        }
    }
}
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    if (check > 0)
    {
        RadGrid1.MasterTableView.Items[check].Expanded = true;
    }
}


Also refer the code library:
Retain expanded/selected state in hierarchy on rebind


-Shinu.
Tags
Grid
Asked by
Justin Lee
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or