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.

Removing Visible Columns in Hierarchy Grid Dynamically

Thread ID:

Created:

Updated:

Platform:

Replies:

98030 Jan 26,2011 04:15 PM Jan 27,2011 11:51 PM ASP.NET Web Forms (Classic) 1
loading
Tags: GridGroupingControl
Adrian Peoples
Asked On January 26, 2011 04:15 PM

Hello. I am a licensed user of Syncfusion EssentialGrid Version 8.4.0.10

I have used the online samples that came with the installation to setup a 3-Level Hierarchy grid. However, when I expand the parent and child tables I see columns that I don't want to see. I thought that I could hide the columns when the row was expanded, but the sample code below does not work:

protected void ggcAssess_RecordExpanded(object sender, RecordEventArgs e)
{
foreach (GridNestedTable nt in e.Record.NestedTables)
{
//Set AllowNew property for the nested tables
nt.ChildTable.ParentTableDescriptor.AllowNew = false;

//attempt to hide columns
if (nt.ChildTable.Name == "Standards")
{
nt.ChildTable.EngineTable.TableDescriptor.VisibleColumns.Remove("standard_section_code");
nt.ChildTable.EngineTable.TableDescriptor.VisibleColumns.Remove("standard_code");
}
else if (nt.ChildTable.Name == "Indicators")
{
nt.ChildTable.EngineTable.TableDescriptor.VisibleColumns.Remove("standard_code");
}
}
}


I am unclear which event I should use to hide child and grandchild columns dynamically. Can anyone help me please?


Sridhar N [Syncfusion]
Replied On January 27, 2011 11:51 PM

Hi Adrian,

Thanks for using Syncfusion Products.

Query 1 : "I have used the online samples that came with the installation to setup a 3-Level Hierarchy grid. However, when I expand the parent and child tables I see columns that I don't want to see. I thought that I could hide the columns when the row was expanded, but the sample code below does not work"

Your requirement to hide the childtable columns dynamically can be achieved by removing the visible columns from the child table in the recordexpanded event. Please refer the below code snippet.

[Codebehind-C#]

protected void GridGroupingControl1_RecordExpanded(object sender, Syncfusion.Grouping.RecordEventArgs e)
{
foreach (GridNestedTable nt in e.Record.NestedTables)
{
if (nt.ChildTable.Name == "MyChildTable")
{
nt.ChildTable.ParentTableDescriptor.VisibleColumns.Remove("ParentID");
}
else if (nt.ChildTable.Name == "MyChildTable1")
{
nt.ChildTable.ParentTableDescriptor.VisibleColumns.Remove("ChildID");
}
}
}


For your convenience, we have created a sample and the same can be downloaded from the following link.

Hierarchy-2136685208.zip

Please let us know your concerns.

Regards,
Sridhar.N




CONFIRMATION

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.

;