GridGrouping Groups programmatically

Hi,

we are using a GGC. Assuming we are grouping with a column called "City". This column is removed from the VisibleColumns of the grid.

Now we have multiple entries with different city groups. Now when a user deletes all rows with a city called "San Diego" (e.g.) then the group disappears.

Now what I want is to stay the group even if the last row with "San Diego" was deleted. Because later on the user is able to add a new row for the "San Diego" group again.

Is this possible?

Any help would be great.

Cheers,
Franz

4 Replies

AD Administrator Syncfusion Team August 8, 2006 02:38 PM UTC

Hi,

I thought of empty groups to solve that issue, but
I have just read in the forum that empty groups are not possible - that''s fatal for me.

I don''t wanna implement that with multiple tables in a dataset. The grouping feature with just one table seems fairly enough for my needs. So is there a workaround to solve my problem (with hidden rows or something like that)?

Need help please!

Cheers,
Franz


AD Administrator Syncfusion Team August 9, 2006 06:29 AM UTC

Hi Franz,

Could you try this code to cancel the grid''s RecordDeleting event when the parentgroup having one record andthen set the record height to zero. Here is a code snippet.

private void gridGroupingControl1_RecordDeleting(object sender, Syncfusion.Grouping.RecordEventArgs e)
{
GridGroupingControl grid = sender as GridGroupingControl;
Group group = e.Record.ParentGroup;
if(group.GetRecordCount() == 1)
{
int RowIndex = grid.Table.DisplayElements.IndexOf(e.Record);
((IGridRowHeight)grid.TableControl.GetTableViewStyleInfo(RowIndex,0).TableCellIdentity.DisplayElement).RowHeight = 0;
e.Cancel = true;
grid.Refresh();
}
}

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GGCAutoHeightAndResize_92b0b30e.zip

Please let me know if this helps.
Best Regards,
Haneef


AD Administrator Syncfusion Team August 9, 2006 01:13 PM UTC

Hi Haneef,

this seems to be a good approach to solve the issue. Another one could be to use multiple tables (with the same columns and so on) in one dataset to simulate the grouping with one table. The only problem with that approach is the different width of the tables (the group cells) in the GGC. For example:

--------------------------------
| Table A |
---------------------------------------
| Table B |
---------------------------------------
| Table C |
-----------------------


But all tables have the same columns (but with different cell content length). Is it possible to
make all tables (table groups) the same length to
simulate a single table with grouping enabled? So
something like this would be great:

---------------------------------------
| Table A |
---------------------------------------
| Table B |
---------------------------------------
| Table C |
---------------------------------------

Any ideas?

Cheers,
Franz


AD Administrator Syncfusion Team August 10, 2006 07:04 AM UTC

Hi Franz,

Try setting the AllowCalculateMaxColumnWidth property to false to resolve this.

//sets the maximum number of characters found in record field cells should be calculated for columns.
this.grid.TableDescriptor.AllowCalculateMaxColumnWidth = false;

//For particular table
this.grid.GetTableDescriptor("TableName").AllowCalculateMaxColumnWidth = false;

Let me know if this helps.
Thanks,
Haneef

Loader.
Up arrow icon