Hello,
I want to prevent the user from grouping when the grid is currently in edit or insert mode.
For the sort command, I did this in GridItemCommand:
But the grouping won't call the GridItemCommand event handler. How can I cancel the grouping?
I want to prevent the user from grouping when the grid is currently in edit or insert mode.
For the sort command, I did this in GridItemCommand:
public bool IsInEditMode { get { return MasterTableView.IsItemInserted || EditItems.Count > 0; } }private void _GridItemCommand(object sender, GridCommandEventArgs e){ if (IsInEditMode && e.CommandName == RadGrid.SortCommandName) { e.Canceled = true; }But the grouping won't call the GridItemCommand event handler. How can I cancel the grouping?
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 22 Jan 2013, 04:39 AM
Hi,
Please try the following code snippet to prevent Grouping on edit/Insert.
C#:
Thanks,
Shinu.
Please try the following code snippet to prevent Grouping on edit/Insert.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridEditableItem && e.Item.IsInEditMode) { RadGrid1.GroupingEnabled = false; RadGrid1.ShowGroupPanel = false; } }Thanks,
Shinu.
0
JP
Top achievements
Rank 1
answered on 22 Jan 2013, 08:52 AM
Hi,
this will indded disable the grouping, but when the grid leaves the edit mode, the grouping panel is still disabled although the Grouping gets enabled in OnLoad (including ShowGroupPanel=true).
this will indded disable the grouping, but when the grid leaves the edit mode, the grouping panel is still disabled although the Grouping gets enabled in OnLoad (including ShowGroupPanel=true).
0
Shinu
Top achievements
Rank 2
answered on 22 Jan 2013, 09:11 AM
Hi,
Please try the following code snippet as well.
C#:
Thanks,
Shinu.
Please try the following code snippet as well.
C#:
protected void Page_Load(object sender, EventArgs e){ RadGrid1.GroupingEnabled = true; RadGrid1.ShowGroupPanel = true; }Thanks,
Shinu.
0
JP
Top achievements
Rank 1
answered on 22 Jan 2013, 10:33 AM
The second snippet works, but after a postback (e.g. in the edit form) the Grouping gets enabled again.
It seems that I need to disable the GroupingPanel/GroupPanel in a method which will get called during every postback. Would the Grid's PreRender event handler be the best place for this?
It seems that I need to disable the GroupingPanel/GroupPanel in a method which will get called during every postback. Would the Grid's PreRender event handler be the best place for this?
0
Shinu
Top achievements
Rank 2
answered on 23 Jan 2013, 04:02 AM
Hi,
Please try the following code snippet in the PreRender event.
C#:
Thanks,
Shinu.
Please try the following code snippet in the PreRender event.
C#:
protected void RadGrid1_PreRender(object sender, EventArgs e){ RadGrid1.GroupingEnabled = true; RadGrid1.ShowGroupPanel = true; RadGrid1.Rebind(); }Thanks,
Shinu.