We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Problem in grouping using with nested tables

Thread ID:





32598 Aug 4,2005 04:38 AM Aug 4,2005 10:57 AM Windows Forms 5
Tags: GridControl
Prathima Venkobachar
Asked On August 4, 2005 04:38 AM

Hi, In gridGroupingControl, I am using nestedtables. This is working fine.But when I try to do the grouping it is not working properly. I am pasting code snippet to show how am I binding.. //Clear all auto populated columns before binding it to the grid GridTableDescriptor tableDescriptor = sfgAssetView.TableDescriptor; tableDescriptor.Columns.Clear();// don''yt clear these we''ll need them tableDescriptor.VisibleColumns.Clear(); tableDescriptor.GroupedColumns.Clear(); foreach(GridSummaryRowDescriptor rd in sfgAssetView.TableDescriptor.SummaryRows) rd.SummaryColumns.Clear(); tableDescriptor.SummaryRows.Clear(); tableDescriptor.SortedColumns.Clear(); tableDescriptor.ExpressionFields.Clear(); tableDescriptor.ResetSummaries(); srcDataSet.Relations.Add( srcDataSet.Tables[0].Columns[DBColumns.AssetId], srcDataSet.Tables[1].Columns[DBColumns.AssetId]); srcDataSet.Relations[0].RelationName = "AssetView_History"; gridGroupingControl.DataSource = srcDataSet.tables[0]; if (gridGroupingControl.TableModel.Table != null) { sfgAssetView.TableModel.Table.ResetRepaintElementsInQueue(); } this.gridGroupingControl.TableDescriptor.Columns.LoadDefault(); GridTableDescriptor tableDescriptor = this.sfgAssetView.TableDescriptor; //Adding it to visible column list this.gridGroupingControl.TableDescriptor.Columns.Add(ColDescriptor); this.gridGroupingControl.TableDescriptor.VisibleColumns.Add(ColDescriptor.Name); // Setting styles to the columns //setting grouping columns //setting frozen columns. when I load for the first time it works fine.The data displays correctly. After loading When I try to group by any field...I get a error in the this line : this.gridGroupingControl.TableDescriptor.Columns.LoadDefault(); - saying "object reference not set to an instance" Thanks, Prathima

Administrator [Syncfusion]
Replied On August 4, 2005 05:37 AM

>>When I try to group by any field...I get a error in the this line : this.gridGroupingControl.TableDescriptor.Columns.LoadDefault(); Why is your LoadDefault() call being hit when you try to group by? Shouldn''t every thing be set up before you add a col to the GroupedColumns collection?

Prathima Venkobachar
Replied On August 4, 2005 05:59 AM

We have a list of group by columns in the dropdown list. User can select the column that can be grouped. So everytime the user selects the groupby, Onchange of the dropdown value, we redo the binding and set the groupby columns. Basically our application is dynamic. The user can select/deselct the columns to be displayed in the grid. The user can select the columns to be grouped. The user can select the frozen columns. We are rebinding everytime the user changes any selection. Thanks, prathima

Administrator [Syncfusion]
Replied On August 4, 2005 08:20 AM

If all your user is doing is specifying a grouping without changing the datasource or displayed columns, then you might want to consider a having a path through your initialization code that just does the grouping in this case. Clearing columns and adding them back in is an overhead that serves no grid purpose in this case. Having a special path through your code would also probably avoid this problem you are seeing. I think it is being caused by this design feature of the grid. The grid delays actually performaing changes to things like the column collection until the next time the collection is actually accessed for some reason. So, in your case, you set enter your initialization code with an exisiting column setup. When the initialization code is completed, the final column setup is exactly the same as the one that it started with (since specifying a group does not affect the actual column collection.) So, one thing you can try is to explicitly access the collection before you are getting teh exception. So, right ahead of the LoadDefault call, add this line: int count = grid.TableDescriptor.Columns.Count; This should force the column collection to be reset. If it does not and count still comes back zero, then you can try manually adding the columns back to TabelDescriptor.Columns.

Prathima Venkobachar
Replied On August 4, 2005 09:02 AM

I am still getting count as zero. What do you mean by manually adding columns..? I should not do load default().. One more I have observed...firsttime when I load also the count comes zero but it works fine..I don''t get that error... Thanks, prathima

Administrator [Syncfusion]
Replied On August 4, 2005 10:57 AM

>>What do you mean by manually adding columns..? I mean calling TableDescriptor.Columns.Add to add the columns back in. What happens if you comment out you line that clears the columns. tableDescriptor.Columns.Clear(); but keep the other lines you have that clear the other collections?


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.