I am using code very similar to the example in the article entitled "Binding to a Hierarchical SQL Database". My parent fields are KeyPrefix,ObjTypeDescr,aTypeID my Child Fields are ObjKey,ObjName,bTypeID.
In FieldLayoutInitialized I set the Visibility of the "aTypeID' column to false. I want to do the same with bTypeID. When I check the fields as below
MsgBox(e.FieldLayout.Fields(3).Name)
I see my fourth "field" is "Hierarchy" and I do not see the fifth and sixth fields. I would be obliged if someone could post some sample code so that I could understand how I can interogate my fourth field object to discern the actual column names for the purpose of setting their visibility to false.
Thanks
Hello,
The fourth field that you see is for creating hierarchy and not the actual field from your child table. What you need to do is the same thing you do with the parent table in the FieldLayoutInitialized event. This event will be fired when each fieldlayout is expanded. So, when you first load the data, only one field layout will be generated - parent layout. When you expand any record, this event will fire for the child layout so you can set the Visibility of the ID column there.
Let me know if you have further questions on this.
Alex, I do not understand which event you are talking about. Do you mean I add more code to the FieldLayoutInitialized event? If so how do I reference the children of "Hierarchy"? NotE I have already tried accessing the child fields directly in this example. I am using .NET. A simple example would help a lot.
John
John,
Your FieldLayoutInitialized event will fire for each fieldlayout when it becomes visible. To hide the ID fields, you can use one code for all the field layouts, something like this:
void xamDataGrid1_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e)
{
// Collapse the First field in every FieldLayout (my First field is always the ID field)
e.FieldLayout.Fields[0].Visibility = Visibility.Collapsed;
// If you have many ID fields:
// Collapse all the fields that are ID - contains "ID"
foreach (Field f in e.FieldLayout.Fields)
if (f.Name.Contains("ID"))
f.Visibility = Visibility.Collapsed;
}
I am attaching the project that I am using. You might also want to look at this example forum post by Aaron Marisi here :
http://community.infragistics.com/forums/p/27159/99761.aspx#99761
Hope this helps.