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. Image for the cookie policy date

Grid to not Expand Child with no data

Hi, I am having an issue with your grid grouping control. I have a parent Child table relation type grid and some parents have no children. However when I use the command GridGroupingControl1.Table.ExpandAllRecords() It expands the parents with no children and shows the column headers of the child table. Is there a way to either cancel the row.expanding method or to set the grid to not expand parents with no children. I have removed the plus signs by making the cell = "Static" but GridGroupingControl1.Table.ExpandAllRecords seems to ignore that the parents have no plus sign. Regards, Chris Wescott

8 Replies

AD Administrator Syncfusion Team April 11, 2006 07:10 AM UTC

Hi Chris, The parent records that have no child record can be prevented from expanding by handling the Table.RecordExpanding event and by setting the e.Cancel to true when there is no child records for a parent record. Below is a code snippet. private void Table_RecordExpanding(object sender, RecordEventArgs e) { if(e.Record.GetRelatedChildTable(new RelationDescriptor("ParentToChild")).GetRecordCount() == 0) e.Cancel = true; } Regards, Calvin.


CW Chris Wescott April 11, 2006 08:06 PM UTC

Hi, This doesn''t seem to work perhaps I am firing it on the wrong event but there is no table.recordexpanding event for the GGC Here is a code snippet Private Sub GridGroupingControl1_RecordExpanding(ByVal sender As System.Object, ByVal e As Syncfusion.Grouping.RecordEventArgs) Handles GridGroupingControl1.RecordExpanding If e.Record.HasNestedTables = False Then e.Cancel = True End If End Sub Vb Examples are best for me as that is what I am writing in, any ideas? Thanks, Chris Wescott


AD Administrator Syncfusion Team April 12, 2006 05:36 AM UTC

Hi Chris, Attached is a sample in both CS and VB. Regards, Calvin.

42938.zip


CW Chris Wescott April 12, 2006 01:39 PM UTC

Thanks Calvin, It works Great!!!


AV avinash February 24, 2011 10:33 PM UTC

I am not able to download the code.



JJ Jisha Joy Syncfusion Team February 25, 2011 05:04 AM UTC

Hi Avinash,

I could able to download it. Please use the following link to the sample.

Regards,
Jisha



42938_cdd76c6d.zip


RA rayzhahng July 9, 2011 09:21 PM UTC

Hi,

Anyone can tell me how to get rid of the plus/minus sign if the parent record does not have any childrens?


And is it possible to move the plus/minus sign to some other cell instead of the first cell if the parents do have childrens?

Thanks much



JJ Jisha Joy Syncfusion Team July 11, 2011 06:21 AM UTC

Hi,

The ChildTable can be made hidden when it has no records to show up, by having a CustomEngine. Derive the GridChildTable in the CustomGroupingEngine and override the GetVisibleCount(), there check whether Records.Count equals 0 for the childtable and return 0. This will make the ChildTable to be hidden when it has no records to show.
In addtion, if the +/- buttons also has to be hidden then, the QueryCellStyleInfo event of the GridGroupiingControl can be handled to do this.
Please refer to the sample,

http://help.syncfusion.com/samples/kb/grid.windows/GGCHideEmptyChildTable/HideEmptyChildTables.zip


Regards,
Jisha


Loader.
Live Chat Icon For mobile
Up arrow icon