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.

Hierarchical GDBG problem

Thread ID:

Created:

Updated:

Platform:

Replies:

51033 Oct 26,2006 08:53 AM Oct 27,2006 08:22 AM Windows Forms 1
loading
Tags: GridControl
Simon Kakon
Asked On October 26, 2006 08:53 AM

Hi,
I would like to allow a user to display data from a datatable and in option to display the data in hierarchical format.
The scenario is :
1- I Init the gdbg with a datatable.
2- Dynamically, I display the data in hierachical format by adding relations ...
3- I remove all relations, and I display the data in a non hierachical format. All this works fine.
4- But when I try to re-display the data in hierachical format, it doesn't work. I have an empty grid.

The source code is :

-------------------------------------------------
// Display Hierarchical Data
public void GroupBy(String colname) {
this.internalGrid.BeginUpdate();
this.internalGrid.BeginInit();
this.internalGrid.ShowTreeLines = true;
this.internalGrid.Binder.ResetHierarchyLevels();
this.internalGrid.IndentHierarchies = true;

DataSet ds = GetDataSet();
ds.Tables.AddRange(new DataTable[] {_dataTableParent});

DataRelation parentToChild = new DataRelation ("ParentToChild",_dataTableParent.Columns[colname], _model.Data.Columns[colname], false);

ds.Relations.AddRange(new DataRelation[] {parentToChild});

this.internalGrid.Binder.SetDataBinding(ds, _dataTableParent.TableName);
this.internalGrid.DataSource = ds;
this.internalGrid.DataMember = _dt.TableName;
this.internalGrid.EndInit();

GridHierarchyLevel level0 = this.internalGrid.Binder.RootHierarchyLevel;
GridHierarchyLevel level1 = this.internalGrid.Binder.AddRelation("ParentToChild");

this.internalGrid.EndUpdate();
}

// Display in "Normal" Format
public void RemoveLink() {
DataSet ds = _model.Data.DataSet;
DataTable _dt = ds.Tables["ParentTable"];
this.internalGrid.BeginUpdate();
this.internalGrid.Binder.ResetHierarchyLevels();
_dt.ChildRelations.Clear();
ds.Tables.Remove("ParentTable");
this.internalGrid.BeginInit();
this.internalGrid.DataMember = null;
this.internalGrid.DataSource = null;

this.internalGrid.DataSource = _model.Data;
this.internalGrid.EndInit();
this.internalGrid.ShowTreeLines = false;
this.internalGrid.EndUpdate();
}
-------------------------------------------------

Thanks a lot for your help.
Sim







Administrator [Syncfusion]
Replied On October 27, 2006 08:22 AM

Hi Sim,

To show the relation in a grid( after changing the relation to underlying datasource), you need to call the AddRelation method. Below is a code snippet

GridHierarchyLevel childrenLevel =gridDataBoundGrid1.Binder.AddRelation("Parent_Child");
childrenLevel.ShowHeaders = false;

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/MasterRelationReset_e5e3bf67.zip

Let me know if this helps.
Best Regards,
Haneef

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.

;