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
close icon

Hiding empty nested table

Following from sample “Hierarchy Demo” in the Syncfusion Essential Studio 2010 v2: I am trying to create a hierarchical grid such that:
The data context contains a collection of parent(Parents)
parent contains a collection of child(Children)
Children is to be rendered as child rows of a parent.
If Children.Count = 0 don’t display and Children for given parent.

How do I go about this using syncfusion and wpf.

Please see attached source. I am basically trying to get rid of the displayed empty table under parent Bob.

Help will be greatly appreciated. Thanks. Wale



WpfBindingTest_47ba83f5.zip

3 Replies

RA Rajasekar Syncfusion Team April 6, 2011 03:12 PM UTC

Hi Wale,

Thanks for your using Syncfusion products.

You can achieve your requirement by invoking the ‘SetHidden” method of GridDataTable.Model.RowHeights in the RecordExpanding event of the DataGrid.Model.Table like shown below,

Here is the code snippet that resolves the issue.

Code Snippet[C#]

this.summaryDataGrid.Model.Table.RecordExpanded += new System.EventHandler>(Table_RecordExpanded);

void Table_RecordExpanded(object sender, GridDataValueEventArgs e)
{
GridDataTable table = sender as GridDataTable;
GridControlBase gcb = table.Model.Views.First();
Point pt = Mouse.GetPosition(gcb);
RowColumnIndex cell = gcb.PointToCellRowColumnIndex(pt);
GridDataRecord rec = e.Value;
int rowIndex = cell.RowIndex + 1;
int count = rec.ChildViews.Count;
for (int i = 0; i < count; ++i)
{
if (rec.ChildModels[i].RowCount < 2)
{
table.Model.RowHeights.SetHidden(rowIndex, rowIndex, true);
}
rowIndex++;
}
}

Please let us know if you have any queries.

Thanks,
Rajasekar





AD Administrator Syncfusion Team April 7, 2011 08:36 AM UTC

That works fine...thanks. But I would have expected to have a Property support for this.



RA Rajasekar Syncfusion Team April 9, 2011 07:27 AM UTC

Hi Wale,

Thanks for your update.

We will consider this as feature and we will provide you the separate property support for this in our 2011 Vol3 release. We will update you once the feature is implemented. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity.

Please let us know if you have any queries.

Thanks,
Rajasekar


Loader.
Live Chat Icon For mobile
Up arrow icon