The Ultratree control that is bound to a business object collection displays everything, I need to control the columns displayed and column format? How can I do it? Is it possible with using ColumnSet on a databound Ultratree?
And the UltraTree is bound to the collection in runtime
Yes, you can control which columns are displayed. There are two ways to do it.
1) If all of the columns are showing up, it's probably because the tree is automatically generating the ColumnSets from the data source. This is the default, but you can turn this off with the AutoGenerateColumnSets property on the ColumnSettings. If you turn this off, you will need to create all of the columnsets yourself and assign them to the correct levels.
2) The second option is to let the tree create the ColumnSets like it's already doing, then modify them. You can do this in the ColumnSetGenerated event. In this event, you can examine the ColmunSet that was created and modify it any way you like - such as removin or hiding columns.
I was able to control the columns being displayed. I had a create a columnset, populate that columnset with the properties of business objects (since columns are treated as properties) and then decide which columns to display and hide. Not an easy task however.
Creating a ColumnSet yourself from scratch is more complicated than simply handling the ColumnSetGenerated event. It's slightly more efficient, though, since you don't end up creating and then removing unneccessary columns.
Now you tell me, j/k. I checked out the ColumnSetGeneratedEvent, I guess it does the same thing few less lines of Code. But the way I did it was little bit more complicated. Here's some code if anyone is interested in future
rootColumnSet.Key =
{
rootColumnSet.Columns.Add(p.Name);
}
rootColumnSet.ColumnSettings.CellAppearance.BackColor =
rootColumnSet.Columns[
Hi
Thanks for the help, i got the same prolem but mine is slightly different, as i have 3 tables in dataset which has to display as child nodes for each table
i got the results but am unable to hide columns in child records
please see the code below
mDSDocumentation =
Nothing
mProAdminDoc =
CType(Session.CreateProvider(AdminProviderTypes.Documentation), EDProAdminDocumentation) mDSDocumentation = mProAdminDoc.GetAdminDocCategoryTabs(strCategory) utAvailableListTree.ViewStyle = Infragistics.Win.UltraWinTree.ViewStyle.Standard utAvailableListTree.DisplayStyle = Infragistics.Win.UltraWinTree.UltraTreeDisplayStyle.Standard utAvailableListTree.ColumnSettings.AutoGenerateColumnSets =
mDSDocumentation = mProAdminDoc.GetAdminDocCategoryTabs(strCategory)
utAvailableListTree.ViewStyle = Infragistics.Win.UltraWinTree.ViewStyle.Standard
utAvailableListTree.DisplayStyle = Infragistics.Win.UltraWinTree.UltraTreeDisplayStyle.Standard
utAvailableListTree.ColumnSettings.AutoGenerateColumnSets =
True
' Get the DataColumn objects from Three DataTable objects in a DataSet.
Dim parentColumn As DataColumn = mDSDocumentation.Tables(0).Columns("tab_id")
Dim childColumn As DataColumn = mDSDocumentation.Tables(1).Columns("parent_tab_id")
Dim childColumn1 As DataColumn = mDSDocumentation.Tables(1).Columns("tab_id")
Dim grandchildColumn As DataColumn = mDSDocumentation.Tables(2).Columns("parent_tab_id")
'Create DataRelation.
Dim relFirstLevel AsDataRelation
Dim relSecondLevel AsDataRelation relFirstLevel =
relFirstLevel =
New DataRelation("FirstRelation", parentColumn, childColumn) relSecondLevel =
relSecondLevel =
New DataRelation("SecondRelation", childColumn1, grandchildColumn)
' Add the relation to the DataSet.
mDSDocumentation.Relations.Add(relFirstLevel) mDSDocumentation.Relations.Add(relSecondLevel)
mDSDocumentation.Relations.Add(relFirstLevel)
mDSDocumentation.Relations.Add(relSecondLevel)
'Binding the Datasource with Tree Control
utAvailableListTree.DisplayStyle = Infragistics.Win.UltraWinTree.UltraTreeDisplayStyle.Standard utAvailableListTree.ViewStyle = Infragistics.Win.UltraWinTree.ViewStyle.Grid utAvailableListTree.DataSource = mDSDocumentation.Tables(0) utAvailableListTree.SetDataBinding(mDSDocumentation.Tables(0),
utAvailableListTree.ViewStyle = Infragistics.Win.UltraWinTree.ViewStyle.Grid
utAvailableListTree.DataSource = mDSDocumentation.Tables(0)
utAvailableListTree.SetDataBinding(mDSDocumentation.Tables(0),
"")
'To Make the Header False in the tree view
utAvailableListTree.ColumnSettings.LabelPosition = Infragistics.Win.UltraWinTree.NodeLayoutLabelPosition.None utAvailableListTree.ColumnSettings.CellAppearance.BackColor = Color.Transparent utAvailableListTree.ColumnSettings.CellAppearance.BorderColor = Color.Transparent
utAvailableListTree.ColumnSettings.LabelPosition = Infragistics.Win.UltraWinTree.NodeLayoutLabelPosition.None
utAvailableListTree.ColumnSettings.CellAppearance.BackColor = Color.Transparent
utAvailableListTree.ColumnSettings.CellAppearance.BorderColor = Color.Transparent
'To Make the unwanted column to be invisible in tree view
utAvailableListTree.ColumnSettings.ColumnSets(0).Columns(
"tab_id").Visible = False
"tab_name").Visible = True
"discription").Visible = False
"parent_tab_id").Visible = False
"display_order").Visible = False
and the result coming as below
+ Triage
+ 123 Test Testing 12 9
i wish to hide the other columns in child also, any help in this will be most appriciated