Dear Forum,
I am working on a grid that has drag-and-drop grouping enabled, but I want to prevent the highest level of grouping from being dropped, so then the grid will always be grouped by that first data item. But I can find no way to eliminate the "x" from the group header box for that item and I can't seem to work out how to handle the GroupsChanging event and use the GridGroupsChangingAction.Ungroup to keep that item in the grouping expression. Can anyone advise or point me to a working
example?
Thanks,
Celeste
I am working on a grid that has drag-and-drop grouping enabled, but I want to prevent the highest level of grouping from being dropped, so then the grid will always be grouped by that first data item. But I can find no way to eliminate the "x" from the group header box for that item and I can't seem to work out how to handle the GroupsChanging event and use the GridGroupsChangingAction.Ungroup to keep that item in the grouping expression. Can anyone advise or point me to a working
example?
Thanks,
Celeste
11 Answers, 1 is accepted
0

Ernest Mombay
Top achievements
Rank 1
answered on 30 Nov 2010, 07:56 PM
I'm also interested in a solution for this. Thanks for any help!
0

Ernest Mombay
Top achievements
Rank 1
answered on 30 Nov 2010, 09:09 PM
To prevent ungrouping of all groups, there's a setting called GroupSettings and you can specifiy whether to prevent ungrouping or not.
<
GroupingSettings
ShowUnGroupButton
=
"false"
/>
To me this solved my problem. From your case however, you only want to prevent ungrouping on the first group and allow ungrouping for subsequent groups. To that, I do now know the answer.
0

Celeste
Top achievements
Rank 1
answered on 30 Nov 2010, 09:43 PM
Ernest,
Thanks. That setting actually did not work at all for me, I still was able to ungroup my groups. And that is right, I only want to ensure that the top level grouping is never ungrouped.
Celeste
Thanks. That setting actually did not work at all for me, I still was able to ungroup my groups. And that is right, I only want to ensure that the top level grouping is never ungrouped.
Celeste
0
Hi Celeste,
You can achieve the following functionality by handling the GroupsChanging event and canceling the ungrouping if you have only one group expression, you also handle there the logic for showing and hiding the ungroup button for the grid. Here is a code snippet of the logic in the event handler, I have also attached the full working project for your convenience:
All the best,
Marin
the Telerik team
You can achieve the following functionality by handling the GroupsChanging event and canceling the ungrouping if you have only one group expression, you also handle there the logic for showing and hiding the ungroup button for the grid. Here is a code snippet of the logic in the event handler, I have also attached the full working project for your convenience:
protected
void
RadGrid1_GroupsChanging(
object
sender, Web.UI.GridGroupsChangingEventArgs e)
{
RadGrid1.GroupingSettings.ShowUnGroupButton =
true
;
if
(e.Action == Web.UI.GridGroupsChangingAction.Ungroup)
{
if
(e.TableView.GroupByExpressions.Count==1)
{
e.Canceled =
true
;
RadGrid1.GroupingSettings.ShowUnGroupButton =
false
;
}
if
(e.TableView.GroupByExpressions.Count==2)
{
RadGrid1.GroupingSettings.ShowUnGroupButton =
false
;
}
}
}
All the best,
Marin
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Celeste
Top achievements
Rank 1
answered on 07 Dec 2010, 07:17 PM
That code snippet does not work for me, well, it works for one request only, then the X appears again on the first grouping and I can ungroup it...I need to be able to hide the ungroup button for the first group only (and always), not for all the groups.
0
Hello Celeste,
In order to hide the ungroup button only for the first group item you will need to use a client side function that finds this element and hides it. Also to prevent ungrouping only for a certain specific field you can check the group expression by name. If it matches then cancel the grouping. I have updated the previous sample. Here the main changes:
in the groupsChaning event
and on the client to hide the ungroup button (only for the first item)
Hope this helps. Let me know if you have any other questions.
All the best,
Marin
the Telerik team
In order to hide the ungroup button only for the first group item you will need to use a client side function that finds this element and hides it. Also to prevent ungrouping only for a certain specific field you can check the group expression by name. If it matches then cancel the grouping. I have updated the previous sample. Here the main changes:
in the groupsChaning event
protected
void
RadGrid1_GroupsChanging(
object
sender, GridGroupsChangingEventArgs e)
{
if
(e.Action == GridGroupsChangingAction.Ungroup)
{
if
(e.Expression.GroupByFields[0].FieldName==
"DesiredFieldName"
)
{
e.Canceled =
true
;
}
}
}
and on the client to hide the ungroup button (only for the first item)
function
pageLoad() {
var
grid = $find(
"<%=RadGrid1.ClientID %>"
);
$(grid._element).find(
'.rgUngroup'
)[0].style.display =
'none'
;
}
Hope this helps. Let me know if you have any other questions.
All the best,
Marin
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Celeste
Top achievements
Rank 1
answered on 08 Dec 2010, 06:15 PM
Marin,
Thank you, the ungrouping works well for me so far, not quite finished testing all the page action. But the first line of the javascript function throws an error, it does not find the grid at all, but I can't open your example to see how you called this function. It doesn't work on load for me. Also, I do not know what a .rar file is (your attachment)...can you just put your example in a zip file?
Celeste
Thank you, the ungrouping works well for me so far, not quite finished testing all the page action. But the first line of the javascript function throws an error, it does not find the grid at all, but I can't open your example to see how you called this function. It doesn't work on load for me. Also, I do not know what a .rar file is (your attachment)...can you just put your example in a zip file?
Celeste
0
Accepted
Hello Celeste,
In the client function you should reference the grid by its ClientID which is a property of the control. The code snippet uses RadGrid1 as a sample name for the grid - this actually should be the ID of the control from the markup
and referenced in the function:
I have converted the sample project to zip format.
Kind regards,
Marin
the Telerik team
In the client function you should reference the grid by its ClientID which is a property of the control. The code snippet uses RadGrid1 as a sample name for the grid - this actually should be the ID of the control from the markup
<
telerik:RadGrid
Skin
=
"Vista"
ID
=
"RadGrid1"
Width
=
"700px"
DataSourceID
=
"SqlDataSource1"
... >
function
pageLoad() {
var
grid = $find(
"<%=RadGrid1.ClientID %>"
);
$(grid._element).find(
'.rgUngroup'
)[0].style.display =
'none'
;
}
I have converted the sample project to zip format.
Kind regards,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Celeste
Top achievements
Rank 1
answered on 22 Dec 2010, 05:49 PM
Marin,
Thank you! Tested again and working great!
Celeste
Thank you! Tested again and working great!
Celeste
0

Jo
Top achievements
Rank 1
answered on 29 Feb 2012, 08:30 PM
Can any one guide me how to disable the "Drag out of the bar to Ungroup" option from the grid... I disabled the X button however, not able to figure out how to disable the drag option.
Thanks..
Thanks..
0
Hello,
which will disable the option for dragging the columns at all.
If you wish to disable only the drag to ungroup option but still allow drag to group. You can override one of the internal client-side event handlers of the GroupItem like this:
All the best,
Marin
the Telerik team
You can set the
<
ClientSettings
AllowDragToGroup
=
"false"
>
If you wish to disable only the drag to ungroup option but still allow drag to group. You can override one of the internal client-side event handlers of the GroupItem like this:
Telerik.Web.UI.GridGroupPanelItem.prototype._onMouseDownHandler =
function
(e)
{
//prevents ungrouping
return
false
;
}
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.