New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

How to prevent ungrouping columns even from the group panel

DESCRIPTION

Usually, implementing grouping for RadGrid goes along with enabling the ShowGroupPanel property. This container functions as the placeholder where the user can drag columns inside or outside in order to group or ungroup the grid content by the corresponding field: GridGroupPanel

The groups can also be set initially on the mark-up or in the code-behind. You can prefer this grouping structure to remain unchanged and hence the user shouldn't be able to drag a field from the group panel to ungroup.

ungroup

Currently, even if the following properties remain disabled, the user can drag a column and ungroup the grid content:

<ClientSettings AllowDragToGroup="false">
</ClientSettings>
<GroupingSettings ShowUnGroupButton="false" />

SOLUTION

Override the built-in drag handler to remove the ungrouping functionality

<script type="text/javascript">
    Telerik.Web.UI.GridGroupPanelItem.prototype._onMouseDownHandler = function (e) { }
    function pageLoad(app, args) {
        // this part is to remove the dragging message and cursor
        $(".rgGroupItem").removeAttr("title style");
    }
</script>
In this article