I was wondering if it was possible to use a single datasource to be able to build a Single Band Hierarchy view. Basically I am just wanting to do a "group by" to show certain high level information and then be able to expand the drop down which could show detail level information.
From what I have seen, everything is using multiple datasources. I am trying to build all of this stuff dynamically instead of using the designer.
Hi,
Sounds like the self referencing example in the Infragistics Sample browser would help you.
Ed
What am I doing wrong? I am getting my three columns but I am not getting any sub columns....
protected void Page_Load(object sender, EventArgs e)
{ ds = new DataSet(); this.CreateColumns(); NFG_DAL test = new NFG_DAL(); test.OpenConnection(); ds = test.GetLineplan(); this.WebHierarchicalDataGrid1.DataKeyFields = "KEY_ITEM_NUMBER"; this.WebHierarchicalDataGrid1.InitialDataBindDepth = 0; this.WebHierarchicalDataGrid1.InitialExpandDepth = 0; this.WebHierarchicalDataGrid1.ExpandCollapseAnimation.SlideOpenDirection = Infragistics.Web.UI.SlideDirection.Auto; this.WebHierarchicalDataGrid1.ExpandCollapseAnimation.SlideOpenDuration = 300; this.WebHierarchicalDataGrid1.ExpandCollapseAnimation.SlideCloseDirection = Infragistics.Web.UI.SlideDirection.Auto; this.WebHierarchicalDataGrid1.ExpandCollapseAnimation.SlideCloseDuration = 300; this.WebHierarchicalDataGrid1.AutoGenerateBands = false; AddBands(); if (!this.IsPostBack) { Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSource dataSource = new Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSource(); dataSource.ID = "WDS"; //dataSource.DataSource = ds; Infragistics.Web.UI.DataSourceControls.DataView view = new Infragistics.Web.UI.DataSourceControls.DataView(); view.DataSourceID = dataSource.ID; view.ID = "LinePlanDS_View"; view.DataSource = ds; dataSource.DataViews.Add(view); Infragistics.Web.UI.DataSourceControls.DataRelation dr = new Infragistics.Web.UI.DataSourceControls.DataRelation(); dr.ChildColumns = new string[] {"SPEC_STYLE_NUM", "SPEC_STYLE_DESCRIPTION"}; dr.ChildDataViewID = "LinePlanDS_View"; dr.ParentColumns = new string[] { "KEY_ITEM_NUMBER", "KEY_ITEM_DESCRIPTION", "TOP_30_KI_GROUP_ID" }; dr.ParentDataViewID = "LinePlanDS_View"; dataSource.DataRelations.Add(dr); cont.Controls.Add(dataSource); this.WebHierarchicalDataGrid1.DataSource = ds; } test.CloseConnection(); } private void AddBands() { Band styleDetail = new Band(); styleDetail.DataKeyFields = "SPEC_STYLE_NUM, SPEC_STYLE_DESCRIPTION"; styleDetail.Columns.Add(AddColumn("SPEC_STYLE_NUM", "Style #")); styleDetail.Columns.Add(AddColumn("SPEC_STYLE_DESCRIPTION", "Style Description")); styleDetail.DataMember = "LinePlanDS_View"; styleDetail.Key = "SPEC_STYLE_NUM, SPEC_STYLE_DESCRIPTION"; styleDetail.IsSelfReference = true; this.WebHierarchicalDataGrid1.Bands.Add(styleDetail); } private void CreateColumns() { if (!this.IsPostBack) { this.WebHierarchicalDataGrid1.Columns.Add(AddColumn("KEY_ITEM_NUMBER", "KI #")); this.WebHierarchicalDataGrid1.Columns.Add(AddColumn("KEY_ITEM_DESCRIPTION", "Key Item Description")); this.WebHierarchicalDataGrid1.Columns.Add(AddColumn("TOP_30_KI_GROUP_ID", "Top 30 Group")); // this.WebHierarchicalDataGrid1.Columns.Add(Column("SPEC_STYLE_NUM", "Style #")); // this.WebHierarchicalDataGrid1.Columns.Add(Column("SPEC_STYLE_DESCRIPTION", "Style Description")); } } private BoundDataField AddColumn(string fieldName, string headerText) { BoundDataField field = new BoundDataField(true); field.Key = "Key_" + fieldName; field.DataFieldName = fieldName; field.Header.Text = headerText; return field; }
{
ds = new DataSet();
this.CreateColumns();
NFG_DAL test = new NFG_DAL();
test.OpenConnection();
ds = test.GetLineplan();
this.WebHierarchicalDataGrid1.DataKeyFields = "KEY_ITEM_NUMBER";
this.WebHierarchicalDataGrid1.InitialDataBindDepth = 0;
this.WebHierarchicalDataGrid1.InitialExpandDepth = 0;
this.WebHierarchicalDataGrid1.ExpandCollapseAnimation.SlideOpenDirection = Infragistics.Web.UI.SlideDirection.Auto;
this.WebHierarchicalDataGrid1.ExpandCollapseAnimation.SlideOpenDuration = 300;
this.WebHierarchicalDataGrid1.ExpandCollapseAnimation.SlideCloseDirection = Infragistics.Web.UI.SlideDirection.Auto;
this.WebHierarchicalDataGrid1.ExpandCollapseAnimation.SlideCloseDuration = 300;
this.WebHierarchicalDataGrid1.AutoGenerateBands = false;
AddBands();
if (!this.IsPostBack)
Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSource dataSource = new Infragistics.Web.UI.DataSourceControls.WebHierarchicalDataSource();
dataSource.ID = "WDS";
//dataSource.DataSource = ds;
Infragistics.Web.UI.DataSourceControls.DataView view = new Infragistics.Web.UI.DataSourceControls.DataView();
view.DataSourceID = dataSource.ID;
view.ID = "LinePlanDS_View";
view.DataSource = ds;
dataSource.DataViews.Add(view);
Infragistics.Web.UI.DataSourceControls.DataRelation dr = new Infragistics.Web.UI.DataSourceControls.DataRelation();
dr.ChildColumns = new string[] {"SPEC_STYLE_NUM", "SPEC_STYLE_DESCRIPTION"};
dr.ChildDataViewID = "LinePlanDS_View";
dr.ParentColumns = new string[] { "KEY_ITEM_NUMBER", "KEY_ITEM_DESCRIPTION", "TOP_30_KI_GROUP_ID" };
dr.ParentDataViewID = "LinePlanDS_View";
dataSource.DataRelations.Add(dr);
cont.Controls.Add(dataSource);
this.WebHierarchicalDataGrid1.DataSource = ds;
}
test.CloseConnection();
private void AddBands()
Band styleDetail = new Band();
styleDetail.DataKeyFields = "SPEC_STYLE_NUM, SPEC_STYLE_DESCRIPTION";
styleDetail.Columns.Add(AddColumn("SPEC_STYLE_NUM", "Style #"));
styleDetail.Columns.Add(AddColumn("SPEC_STYLE_DESCRIPTION", "Style Description"));
styleDetail.DataMember = "LinePlanDS_View";
styleDetail.Key = "SPEC_STYLE_NUM, SPEC_STYLE_DESCRIPTION";
styleDetail.IsSelfReference = true;
this.WebHierarchicalDataGrid1.Bands.Add(styleDetail);
private void CreateColumns()
this.WebHierarchicalDataGrid1.Columns.Add(AddColumn("KEY_ITEM_NUMBER", "KI #"));
this.WebHierarchicalDataGrid1.Columns.Add(AddColumn("KEY_ITEM_DESCRIPTION", "Key Item Description"));
this.WebHierarchicalDataGrid1.Columns.Add(AddColumn("TOP_30_KI_GROUP_ID", "Top 30 Group"));
// this.WebHierarchicalDataGrid1.Columns.Add(Column("SPEC_STYLE_NUM", "Style #"));
// this.WebHierarchicalDataGrid1.Columns.Add(Column("SPEC_STYLE_DESCRIPTION", "Style Description"));
private BoundDataField AddColumn(string fieldName, string headerText)
BoundDataField field = new BoundDataField(true);
field.Key = "Key_" + fieldName;
field.DataFieldName = fieldName;
field.Header.Text = headerText;
return field;