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

How to do grouping on Array items

3 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ram
Top achievements
Rank 1
Ram asked on 27 Apr 2010, 01:44 PM
hi,

currently I am doing grouping on single values as follows

GridGroupByExpression CountryCategoryExpression = GridGroupByExpression.Parse(" CName [ ],pName[    ProductValues/ServiceValues],sName[/] Group By CName"); 
CountryRadGrid.MasterTableView.GroupByExpressions.Add(CountryCategoryExpression); 

above code works fine for me.

but now my requirement changed as a way that the CName, pName and sName can be multiple (they are coming as array, which is as follows

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 30 Apr 2010, 06:10 AM
Hello Ram,

In this case, you can add the fields as separate groupByExpressions.
Give this approach a try and let me know how it goes, and whether this is the intended layout.

Best wishes,
Yavor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ram
Top achievements
Rank 1
answered on 05 May 2010, 05:17 PM
Thanks Yavor,
i did it in the following way,
GridGroupByExpression expression = new GridGroupByExpression(); 
                                    GridGroupByField gridGroupByField; 
 
 
                                    expression = new GridGroupByExpression(); 
                                    //// SelectFields values (appear in header) 
                                    gridGroupByField = new GridGroupByField(); 
                                    gridGroupByField.FieldName = "branchName"
                                    gridGroupByField.HeaderText = " "
                                    
                                    expression.SelectFields.Add(gridGroupByField); 
 
                                    //// SelectFields values (appear in header) 
                                    gridGroupByField = new GridGroupByField(); 
                                    gridGroupByField.FieldName = "Pname"
                                    gridGroupByField.HeaderText = "      Product/Services"
                                    
                                    expression.SelectFields.Add(gridGroupByField); 
 
                                    gridGroupByField = new GridGroupByField(); 
                                    gridGroupByField.FieldName = "Sname"
                                    gridGroupByField.HeaderText = "/"
                                     
                                    expression.SelectFields.Add(gridGroupByField); 
 
                                    ////GroupByFields values (group data) 
                                    gridGroupByField = new GridGroupByField(); 
                                    gridGroupByField.FieldName = "branchName"
                                    expression.GroupByFields.Add(gridGroupByField); 
 
                                    ////GroupByFields values (group data)            
                                    gridGroupByField = new GridGroupByField(); 
                                    gridGroupByField.FieldName = "Pname"
                                    expression.GroupByFields.Add(gridGroupByField); 
 
                                    ////GroupByFields values (group data)            
                                    gridGroupByField = new GridGroupByField(); 
                                    gridGroupByField.FieldName = "Sname"
                                    expression.GroupByFields.Add(gridGroupByField); 
 
                                    CountryRadGrid.MasterTableView.GroupByExpressions.Add(expression); 

where Sname and Pname are arrays
    Sname=new string[]{"S1","S2"},
    Pname=new string[] {"P1","P2"},

when I am executing the above code I am getting the following error:

Field Pname not found in the source table. Please check the expression syntax.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Telerik.Web.UI.GridGroupByException: Field Pname not found in the source table. Please check the expression syntax.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[GridGroupByException: Field Pname not found in the source table. Please check the expression syntax.]
   Telerik.Web.UI.GridDataSetHelper.CreateGroupByTable(DataTable SourceTable, GridTableView view) +433
   Telerik.Web.UI.GridEnumerableFromDataView.PerformTransformation() +3836
   Telerik.Web.UI.GridEnumerableFromDataView.TransformEnumerable() +18
   Telerik.Web.UI.GridTableView.GetEnumerator(Boolean useDataSource, GridEnumerableBase resolvedDataSource, ArrayList dataKeysArray) +105
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +216
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +608
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +59
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +111
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
   Telerik.Web.UI.GridTableView.PerformSelect() +4
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
   Telerik.Web.UI.GridTableView.DataBind() +304
   Telerik.Web.UI.RadGrid.DataBind() +77
   Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +2340
   Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) +120
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436


0
Iana Tsolova
Telerik team
answered on 11 May 2010, 11:30 AM
Hi Ram,

Could you confirm that the Pname field is bound to a grid column?
Try setting the UseAllDataFields property of the MasterTableView to true and see if it makes any difference.

Sincerely yours,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Ram
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Ram
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or