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

[Solved] Remove tree view structure while grouping in radgrid.

1 Answer 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Medac
Top achievements
Rank 1
Medac asked on 08 Feb 2010, 07:04 AM

Hi ,

We are using Outlook-Style Grouping in our application.

When user drags and drops the column in the Group Panel , records in

grid are grouped based on the selected column.

When user selects more than one column sorted rows are appeared in the

tree view.

Please let us know if we can remove the tree view while grouping.



Regards,
Medac

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Feb 2010, 11:39 AM
Hi Medac,

Try the code snippet below to group without the treeview structure.

C#:
protected void RadGrid1_GroupsChanging(object source, GridGroupsChangingEventArgs e) 
        { 
            if(e.Action == GridGroupsChangingAction.Group) 
            { 
                if (RadGrid1.MasterTableView.GroupByExpressions.Count > 0) 
                { 
                    for (int i = 0; i < RadGrid1.MasterTableView.GroupByExpressions[0].GroupByFields.Count; i++) 
                    { 
                        GridGroupByField newGroupField = new GridGroupByField(); 
                        newGroupField = new GridGroupByField(); 
                        newGroupField.FieldName = RadGrid1.MasterTableView.GroupByExpressions[0].GroupByFields[i].FieldName; 
                        if (!e.Expression.GroupByFields.Contains(newGroupField)) 
                        { 
                            if (e.Expression.SelectFields.FindByName(newGroupField.FieldName) != null
                            { 
                                if (!(e.Expression.SelectFields.FindByName(newGroupField.FieldName).FieldName == newGroupField.FieldName)) 
                                { 
                                    e.Expression.SelectFields.Insert(i, newGroupField); 
                                    e.Expression.GroupByFields.Insert(i, newGroupField); 
                                } 
                            } 
                            else 
                            { 
                                e.Expression.SelectFields.Insert(i, newGroupField); 
                                e.Expression.GroupByFields.Insert(i, newGroupField); 
                            } 
                        } 
 
 
                    } 
                } 
            } 

You would have to use a  similar logic for ungrouping .

For more information refer the help link below:
Set GroupByExpression on drag and drop

Thanks,
Princy

Tags
Grid
Asked by
Medac
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or