Good morning, all.
I have a question regarding the RadGrid's grouping feature. I have an Ajaxified grid binding from a web service, which is allowing grouping and sorting. I also have a separate form that allows users to specify a default grouping level if they so choose. The value is then written to a table in the database.
On the grid's PreRender event, I'm doing a check to see if there are any custom grouping levels specified. If so, I'm able to apply the group to the grid with "RadGrid1.MasterTableView.GroupByExpressions.Add("Group By " & val)" and it renders fine. The issue I'm having is that no other grouping can be applied due to an index error, and this level can't be removed (same index error). I'm only doing the database check the first time the page is loaded so ideally, the user should be able to remove the default group and have it return on the next page load (unless they specify a different default).
As a side note, if the user doesn't have a default group specified, there's no problem with the grid's grouping features at all.
Is there something else I need to do besides add the GroupByExpression in order to enable my dynamic grouping to function with groups dragged to the header row?
Thanks!
/jeff
I have a question regarding the RadGrid's grouping feature. I have an Ajaxified grid binding from a web service, which is allowing grouping and sorting. I also have a separate form that allows users to specify a default grouping level if they so choose. The value is then written to a table in the database.
On the grid's PreRender event, I'm doing a check to see if there are any custom grouping levels specified. If so, I'm able to apply the group to the grid with "RadGrid1.MasterTableView.GroupByExpressions.Add("Group By " & val)" and it renders fine. The issue I'm having is that no other grouping can be applied due to an index error, and this level can't be removed (same index error). I'm only doing the database check the first time the page is loaded so ideally, the user should be able to remove the default group and have it return on the next page load (unless they specify a different default).
As a side note, if the user doesn't have a default group specified, there's no problem with the grid's grouping features at all.
Is there something else I need to do besides add the GroupByExpression in order to enable my dynamic grouping to function with groups dragged to the header row?
Thanks!
/jeff
5 Answers, 1 is accepted
0
Hello Jeff,
A possible reason for this is that Page_PreRender event fires too late for adding group expressions. Please try adding the GroupByExpressions in the Page_Init/Page_Load events and tell us if this has resolved the problem.
Regards,
Angel Petrov
the Telerik team
A possible reason for this is that Page_PreRender event fires too late for adding group expressions. Please try adding the GroupByExpressions in the Page_Init/Page_Load events and tell us if this has resolved the problem.
Regards,
Angel Petrov
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.
0

Jeff
Top achievements
Rank 1
answered on 30 Jan 2013, 07:47 PM
Hi, Angel.
Thanks for your response. I moved the code calling the grouping subroutine to the Page_Init of my control, but I'm still having the same issue. I've whittled it down to the following block:
If I comment that routine out, the groups work. I believe it has something to do with getting it into that GridColumnSafe property, but I can't seem to get the syntax down to add them. Is there a particular way to do this outside of the GroupsChanging event?
Thanks for your response. I moved the code calling the grouping subroutine to the Page_Init of my control, but I'm still having the same issue. I've whittled it down to the following block:
Protected Sub GroupsChanging(ByVal source As Object, ByVal e As GridGroupsChangingEventArgs) Handles radGrid1.GroupsChanging
If (e.Action = GridGroupsChangingAction.Group) Then
radGrid1.MasterTableView.GetColumnSafe(e.Expression.GroupByFields(0).FieldName).Visible = False
ElseIf (e.Action = GridGroupsChangingAction.Ungroup) Then
radGrid1.MasterTableView.GetColumnSafe(e.Expression.GroupByFields(0).FieldName).Visible = True
End If
End Sub
If I comment that routine out, the groups work. I believe it has something to do with getting it into that GridColumnSafe property, but I can't seem to get the syntax down to add them. Is there a particular way to do this outside of the GroupsChanging event?
0
Hello Jeff,
A better approach would be to do grouping outside the GroupsChanging event. For example in the Page_Load event handler. A demonstration of this is shown in the code snippet below:
In order to get a better idea of this I have attached an example in which the grid is initially grouped and you can apply additional grouping without any problems. I strongly suggest that you examine this help article which describes how to apply grouping programmatically.
Regards,
Angel Petrov
the Telerik team
A better approach would be to do grouping outside the GroupsChanging event. For example in the Page_Load event handler. A demonstration of this is shown in the code snippet below:
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Handles
Me
.Load
If
Not
IsPostBack
Then
Dim
expression
As
GridGroupByExpression =
New
GridGroupByExpression
Dim
gridGroupByField
As
GridGroupByField =
New
GridGroupByField
gridGroupByField =
New
GridGroupByField
gridGroupByField.FieldName =
"ContactTitle"
gridGroupByField.HeaderText =
"ContactTitle"
expression.SelectFields.Add(gridGroupByField)
gridGroupByField =
New
GridGroupByField
gridGroupByField.FieldName =
"ContactTitle"
expression.GroupByFields.Add(gridGroupByField)
RadGrid1.MasterTableView.GroupByExpressions.Add(expression)
End
If
End
Sub
Regards,
Angel Petrov
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.
0

Jeff
Top achievements
Rank 1
answered on 04 Feb 2013, 06:54 PM
Hi, Angel.
Thanks for your response. That's what I ended up doing; I'm firing a separate subroutine on the Page_Init that's checking the appropriate settings and adding them. I found out I was configuring and adding the expressions wrong. The dynamic grouping is working so now the only remaining issues are grid alignment and AJAX rebinding. For some reason, if the page is refreshed with these custom groupings, the first column's data starts about where the end of the grouping tag in the group header ends; this throws off the grid's alignment until either a group is dragged into the header or a column is resized. Then the columns snap into place like they should. Do you know what's causing the grid to render off? Is there something else I need to do after applying the grouping?
As for the rebinding, I think I just need to find a way to get the control name passed into the RadAjaxManager properly. Since any of these controls may or may not be there due to user preference, I can't add them to the manager properly.
Thanks again for your help!
Thanks for your response. That's what I ended up doing; I'm firing a separate subroutine on the Page_Init that's checking the appropriate settings and adding them. I found out I was configuring and adding the expressions wrong. The dynamic grouping is working so now the only remaining issues are grid alignment and AJAX rebinding. For some reason, if the page is refreshed with these custom groupings, the first column's data starts about where the end of the grouping tag in the group header ends; this throws off the grid's alignment until either a group is dragged into the header or a column is resized. Then the columns snap into place like they should. Do you know what's causing the grid to render off? Is there something else I need to do after applying the grouping?
As for the rebinding, I think I just need to find a way to get the control name passed into the RadAjaxManager properly. Since any of these controls may or may not be there due to user preference, I can't add them to the manager properly.
Thanks again for your help!
0
Hi Jeff,
About the first problem we would need more information. Please elaborate on in which browser and browser versions does the alignment problem replicates and which version of the controls are you using. Also please send us your markup so we could get a better view over your setup.
The second issue can be resolved by adding the AJAX settings programmatically.
All the best,
Angel Petrov
the Telerik team
About the first problem we would need more information. Please elaborate on in which browser and browser versions does the alignment problem replicates and which version of the controls are you using. Also please send us your markup so we could get a better view over your setup.
The second issue can be resolved by adding the AJAX settings programmatically.
All the best,
Angel Petrov
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.