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

Initialize the Grid Tree Control

I have a question about the Grid Tree Control

When initialize the Grid Tree Control. It seems I need to get three levels' data. It is too inefficient for our project.

I hope only get the data of highest level when initialize(it look like collapse all nodes)


please see the Attachment



Initialize Grid Tree Control _b6ff31f9.rar

3 Replies

CB Clay Burch Syncfusion Team March 9, 2010 12:56 PM UTC

By default, the GridTreeControl loads one level in advance so it knows whether the displayed children need to have an expand glyph or not. There is a HideEmptyChilGlyph property that controls this behavior.

Also, by default, the GridTreeControl displays with the root nodes expanded. To avoid this behavior, you need to set a property on the gridTreeControl.InternalGrid. To set such properties requires that you handle the ModelLoaded event and set the properties in that event (since the InternalGrid has been created when this event is raised).

So, try code like this in that sample to see if it does what you want:


public Window1()
{
InitializeComponent();

//one time, initialize the data access some how...
employees = new EmployeesCollection();
employees.PopulateWithSampleData(500);

treeGrid.ModelLoaded += new EventHandler(treeGrid_ModelLoaded);
treeGrid.HideEmptyChildGlyphs = false; }



void treeGrid_ModelLoaded(object sender, EventArgs e)
{
treeGrid.InternalGrid.ExpandStateAtStartUp = GridTreeStartUpExpandState.NoNodesExpanded;
}


J. J.T March 11, 2010 10:13 AM UTC

Thanks very much for the respond.

I have another question.

Does the GridTreeControl has the ResizingColumns event,because i hope to cancel the default resizing and auto-size it through the "ResizeColumnsToFit" method


CB Clay Burch Syncfusion Team March 11, 2010 12:39 PM UTC

There are a couple of properties specific to the GridTreeControl that affect column widths. The AllowAutoSizingNodeColumn property controls whether the GridTreeControl automatically increases the size of the treenode columns as more levels are exposed. There is also a PercentSizingBehaviorProperty that controls how the GridTreeControl can be set so its columns automatically cover all of the grid's client area.

If you want to make it impossible for your user to size columns through the UI, then you can handle treeGrid.InternalGrid.ResizingColumns event. Below is some code showing how you might set these properties and subscribe to this event in the ModelLoaded event.


void treeGrid_ModelLoaded(object sender, EventArgs e)
{
treeGrid.InternalGrid.ExpandStateAtStartUp = GridTreeStartUpExpandState.NoNodesExpanded;

treeGrid.PercentSizingBehavior = GridPercentColumnSizingBehavior.None;
treeGrid.AllowAutoSizingNodeColumn = false;

treeGrid.InternalGrid.ResizingColumns += new GridResizingColumnsEventHandler(InternalGrid_ResizingColumns);
}

void InternalGrid_ResizingColumns(object sender, GridResizingColumnsEventArgs args)
{
args.AllowResize = false;
}

Loader.
Live Chat Icon For mobile
Up arrow icon