RadGrid for ASP.NET

RadGrid Send comments on this topic.
GroupsChanging Event
See Also  Example
Telerik.WebControls Namespace > RadGrid Class : GroupsChanging Event


Fires when a grouping action has been performed. For example when a column header was dragged in the GroupPanel.   

Event Data

The event handler receives an argument of type GridGroupsChangingEventArgs containing data related to this event. The following GridGroupsChangingEventArgs properties provide information specific to this event.

PropertyDescription
Action Gets a reference to GridGroupsChangingAction enumeration, which holds information about what action did fire the RadGrid.GroupsChanging event.
Canceled Gets or sets a value indicating whether RadGrid.GroupsChanging event will be canceled.
Expression Gets or sets the GridGroupByExpression that will be used for grouping Telerik RadGrid.
SortedField Gets a reference to the currently used GridGroupByField.
SwapExpression  
TableView Gets a reference to the GridTableView object where the grouping is performed.
 

 

Namespace: Telerik.WebControls
Assembly: RadGrid (in RadGrid.dll)

Syntax

Visual Basic (Declaration) 
Public Event GroupsChanging() As GridGroupsChangingEventHandler
Visual Basic (Usage)Copy Code
Dim instance As RadGrid
Dim handler As GridGroupsChangingEventHandler
 
AddHandler instance.GroupsChanging, handler
C# 
public event GridGroupsChangingEventHandler GroupsChanging()
 

Event Data

The event handler receives an argument of type GridGroupsChangingEventArgs containing data related to this event. The following GridGroupsChangingEventArgs properties provide information specific to this event.

PropertyDescription
Action Gets a reference to GridGroupsChangingAction enumeration, which holds information about what action did fire the RadGrid.GroupsChanging event.
Canceled Gets or sets a value indicating whether RadGrid.GroupsChanging event will be canceled.
Expression Gets or sets the GridGroupByExpression that will be used for grouping Telerik RadGrid.
SortedField Gets a reference to the currently used GridGroupByField.
SwapExpression  
TableView Gets a reference to the GridTableView object where the grouping is performed.

Example

C#Copy Code
protected void RadGrid1_GroupsChanging(object source, Telerik.WebControls.GridGroupsChangingEventArgs e)
{
//Expression is added (by drag/grop on group panel)

 
if (e.Action == GridGroupsChangingAction.Group)
{
 
if (e.Expression.GroupByFields[0].FieldName != "CustomerID")
 {
  GridGroupByField countryGroupField =
new GridGroupByField();
  countryGroupField.FieldName =
"Country";
  GridGroupByField cityGroupField =
new GridGroupByField();
  cityGroupField.FieldName =
"City";

  e.Expression.SelectFields.Clear();
  e.Expression.SelectFields.Add(countryGroupField);
  e.Expression.SelectFields.Add(cityGroupField);

  e.Expression.GroupByFields.Clear();
  e.Expression.GroupByFields.Add(countryGroupField);
  e.Expression.GroupByFields.Add(cityGroupField);
 }

}
}
    
Visual BasicCopy Code
Protected Sub RadGrid1_GroupsChanging(ByVal source As Object, ByVal e As Telerik.WebControls.GridGroupsChangingEventArgs)
 'Expression is added (by drag/grop on group panel)
  If (e.Action = GridGroupsChangingAction.Group) Then
  If (e.Expression.GroupByFields(0).FieldName <> "CustomerID") Then
   Dim countryGroupField As GridGroupByField = New GridGroupByField
   countryGroupField.FieldName = "Country"
   Dim cityGroupField As GridGroupByField = New GridGroupByField
   cityGroupField.FieldName = "City"
   e.Expression.SelectFields.Clear
   e.Expression.SelectFields.Add(countryGroupField)
   e.Expression.SelectFields.Add(cityGroupField)
   e.Expression.GroupByFields.Clear
   e.Expression.GroupByFields.Add(countryGroupField)
   e.Expression.GroupByFields.Add(cityGroupField)
  End If
 End If
End Sub
C#Copy Code
protected void RadGrid1_GroupsChanging(object source, Telerik.WebControls.GridGroupsChangingEventArgs e)
{
//Expression is added (by drag/grop on group panel)

 
if (e.Action == GridGroupsChangingAction.Group)
{
 
if (e.Expression.GroupByFields[0].FieldName != "CustomerID")
 {
  GridGroupByField countryGroupField =
new GridGroupByField();
  countryGroupField.FieldName =
"Country";
  GridGroupByField cityGroupField =
new GridGroupByField();
  cityGroupField.FieldName =
"City";

  e.Expression.SelectFields.Clear();
  e.Expression.SelectFields.Add(countryGroupField);
  e.Expression.SelectFields.Add(cityGroupField);

  e.Expression.GroupByFields.Clear();
  e.Expression.GroupByFields.Add(countryGroupField);
  e.Expression.GroupByFields.Add(cityGroupField);
 }

}
}
    
Visual BasicCopy Code
Protected Sub RadGrid1_GroupsChanging(ByVal source As Object, ByVal e As Telerik.WebControls.GridGroupsChangingEventArgs)
 'Expression is added (by drag/grop on group panel)
  If (e.Action = GridGroupsChangingAction.Group) Then
  If (e.Expression.GroupByFields(0).FieldName <> "CustomerID") Then
   Dim countryGroupField As GridGroupByField = New GridGroupByField
   countryGroupField.FieldName = "Country"
   Dim cityGroupField As GridGroupByField = New GridGroupByField
   cityGroupField.FieldName = "City"
   e.Expression.SelectFields.Clear
   e.Expression.SelectFields.Add(countryGroupField)
   e.Expression.SelectFields.Add(cityGroupField)
   e.Expression.GroupByFields.Clear
   e.Expression.GroupByFields.Add(countryGroupField)
   e.Expression.GroupByFields.Add(cityGroupField)
  End If
 End If
End Sub

Remarks

You can use this event to set your own GridGroupByExpression when the user tries to group the grid.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also