Bryan Hughes
Top achievements
Rank 1
Bryan Hughes
asked on 24 Apr 2013, 07:49 PM
I have a page that is similar to your Web Mail example. Depending on selected view from TreeList it loads grid in main window. What I would like to do depending on selected view is add or remove grouping from grid. Can you please post an example or link to example to make this work?
Thank you
Thank you
10 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 25 Apr 2013, 04:53 AM
Hi,
You can clear grouping as shown below.
c#
Thanks,
Shinu
You can clear grouping as shown below.
c#
protected void Button1_Click(object sender, System.EventArgs e){ RadGrid1.MasterTableView.GroupByExpressions.Clear(); RadGrid1.Rebind();}Thanks,
Shinu
0
Bryan Hughes
Top achievements
Rank 1
answered on 25 Apr 2013, 05:11 PM
Thank you Shinu. How do I add Grouping dynamicaly server side?
0
Shinu
Top achievements
Rank 2
answered on 26 Apr 2013, 06:42 AM
Hi,
You can add grouping progrmmatically as explained in teh following help documentation.
Programmatic Definition
Thanks,
Shinu
You can add grouping progrmmatically as explained in teh following help documentation.
Programmatic Definition
Thanks,
Shinu
0
Bryan Hughes
Top achievements
Rank 1
answered on 26 Apr 2013, 05:12 PM
Thank you Shinu, that is exactly what I needed. One last question. Should I put the Add/Remove grouping in the NeedDataSource, ItemCreated or other event for grid?
Bryan
Bryan
0
Shinu
Top achievements
Rank 2
answered on 29 Apr 2013, 04:56 AM
Hi,
You can add the code in Prerender event of grid.
c#
Thanks,
Shinu
You can add the code in Prerender event of grid.
c#
protected void RadGrid1_PreRender(object sender, EventArgs e){ RadGrid1.MasterTableView.GroupByExpressions.Clear(); RadGrid1.Rebind();}Thanks,
Shinu
0
Bryan Hughes
Top achievements
Rank 1
answered on 30 Apr 2013, 11:11 PM
I can get it to programmatically group, but once it groups I cannot get it to clear the grouping. It doesn't load the other views, unless I refresh the page.
I am not sure where it is breaking.
Thank you Bryan
protected void RadGrid1_PreRender(object sender, EventArgs e){ string selectedView = RtvFamilyJournal.SelectedNode.Text; bool isWishAdmin = HttpContext.Current.User.IsInRole("WISH Administrator"); bool isAgencyAdmin = HttpContext.Current.User.IsInRole("Agency Administrator"); GridGroupByExpression expression = new GridGroupByExpression(); GridGroupByField gridGroupByField = new GridGroupByField(); switch (selectedView) { case "Assigned": RadGrid1.GroupingEnabled = false; RadGrid1.MasterTableView.GroupByExpressions.Clear(); break; case "Not Approved": RadGrid1.GroupingEnabled = false; RadGrid1.MasterTableView.GroupByExpressions.Clear(); break; case "Agency": RadGrid1.MasterTableView.GroupLoadMode = GridGroupLoadMode.Server; RadGrid1.GroupingEnabled = true; gridGroupByField = new GridGroupByField(); gridGroupByField.FieldName = "ProviderName"; gridGroupByField.FieldAlias = "Name"; gridGroupByField.HeaderText = "Provider"; gridGroupByField.HeaderValueSeparator = " for journals: "; gridGroupByField.FormatString = "<strong>{0}</strong>"; expression.SelectFields.Add(gridGroupByField); gridGroupByField = new GridGroupByField(); gridGroupByField.FieldName = "ProviderName"; expression.GroupByFields.Add(gridGroupByField); RadGrid1.MasterTableView.GroupByExpressions.Add(expression); break; case "Unassigned": RadGrid1.GroupingEnabled = false; RadGrid1.MasterTableView.GroupByExpressions.Clear(); break; case "New Journal": RadGrid1.MasterTableView.GroupByExpressions.Clear(); break; } RadGrid1.Rebind();}I am not sure where it is breaking.
Thank you Bryan
0
Bryan Hughes
Top achievements
Rank 1
answered on 02 May 2013, 05:13 PM
I can get it to work right if I put it as part of Grid Load event, but then custom paging function doesn't work correctly. I am using an Alphabetic with slider paging. If I use the Grouping in grid load event, then the pager has to be clicked twice before it functions.
Thank you,
Bryan
Thank you,
Bryan
0
Hello Bryan,
After calling GroupByExpressions.Clear() you need to call RadGrid1.Rebind() in order to apply the expressions and rebind the grid as Shinu already suggested.
Kind regards,
Vasil
the Telerik team
After calling GroupByExpressions.Clear() you need to call RadGrid1.Rebind() in order to apply the expressions and rebind the grid as Shinu already suggested.
Kind regards,
Vasil
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
Bryan Hughes
Top achievements
Rank 1
answered on 15 May 2013, 06:18 PM
I did add RadGrid1.Rebind(), but it is still having issue. It only works in Grid.Load event, but then the alphabetic pager has to be clicked twice before it fires. If I add to prerender event, then it only loads once for selected view, but will not load when other views are selected.
Thank you,
Bryan
Thank you,
Bryan
0
Hello Bryan,
Based on your description it is hard to determine the cause of the problem. In order to further investigate we will need a sample runnable project showing the unwanted behavior so we could debug it and advice you with the best possible solution. You could open a formal ticket and upload the project there.
Regards,
Antonio Stoilkov
the Telerik team
Based on your description it is hard to determine the cause of the problem. In order to further investigate we will need a sample runnable project showing the unwanted behavior so we could debug it and advice you with the best possible solution. You could open a formal ticket and upload the project there.
Regards,
Antonio Stoilkov
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.