I have used WebHierarchicalDataGrid in my project and I am binding the datasource of the grid using a dataset.
When I set the AutoGenerateBands = "True", then I get a Hierarchical view with all the parent and child columns but as soon as I make this as false and define my own columns in the child band I get only one parent row with no expand arrow and no child rows at all.
I am not able to figure out the problem. Any help will be appreciated.
Aspx Code:
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" AutoGenerateColumns="false"
AutoGenerateBands="false" Height="100%" Width="100%" InitialDataBindDepth="-1"
InitialExpandDepth="0" DataKeyFields="ID_APPLIESTO">
<Columns>
<ig:BoundDataField DataFieldName="APPLIESTO_VALUE" Key="APPLIESTO" Header-Text="Applies To" />
<ig:BoundDataField DataFieldName="ID_APPLIESTO" Key="ID_APPLIESTO" Header-Text="ID_APPLIESTO" />
</Columns>
<Bands>
<ig:Band ShowHeader="true" Key="B1" AutoGenerateColumns="false" DataKeyFields="ID_APPLIESTO">
<ig:BoundDataField DataFieldName="ID_APPLIESTO_GROUP" Key="ID_APPLIESTO_GROUP" Header-Text="ID_APPLIESTO_GROUP" />
</ig:Band>
</Bands>
</ig:WebHierarchicalDataGrid>
Binding Dataset:
oOraAdpt.Fill(ds);
ds.Relations.Add("1", ds.Tables[0].Columns["ID_APPLIESTO"], ds.Tables[1].Columns["ID_APPLIESTO"]);
whdg1.DataSource = ds;
whdg1.DataBind();
Hi,
I took a look at your code and think that if you set the correct DataMember for the grid and the child band it'll fix the issue. If it doesn't please attach a sample WebSite so we can investigate further.
I have the same issue i.e if i put autogeneratebands=true the parent child relation seems fine but when i do autogeneratebands=false and define band myself i dont see the expand/collapse animation. here is my code.
//aspx//
<
="false"
="0">
="Auto"
/>
>
="MKT_AREA">
//code behind//
igV.InitialDataBindDepth = -1;
DataSet ds = new DataSet();
DataTable dt = LeaseNego.getRegions();
DataTable dtArea = LeaseNego.getOpsArea();
ds.Tables.Add(dt); ds.Tables.Add(dtArea);
System.Data.
DataRelation dRelation = new System.Data.DataRelation("RGN_Relation",dt.Columns["RGN_CDE"],dtArea.Columns["RGN_CDE"]);
ds.Relations.Add(dRelation);
igV.DataMember =
"dt"; igV.Bands[0].DataMember = "dtArea";
igV.DataSource = ds;
igV.DataBind();
Thanks kavitha,
but your solution way is also not working. i tried setting autogeneratedbands = true and manualy added the band but it didnt help it is showing me all the columns just like if i dont make bands manually and only set the autogeneratedbands=true.
Anyoen else if you could help that would really be appreciated.
I got same issue.I fixed that issue Making Autogenaratebands=true and created band manually, I am pasting my ocde below.
apsx.cs
protected void Page_Load(object sender, EventArgs e) {
if (!Page.IsPostBack) { this.whdgBigTicket.DataBind();
} } } protected void whdgBigTicket_RowIslandsPopulating(object sender, ContainerRowCancelEventArgs e) { e.Cancel = true; ContainerGrid childBigTicketDetails = new ContainerGrid(); childBigTicketDetails.AutoGenerateColumns = false; childBigTicketDetails.DataKeyFields = "Rep Name,Fund/Manager"; string repname=e.Row.DataKey[0].ToString(); if(repname.IndexOf("'")>0) repname = Regex.Replace(repname, "'", "''");
e.Row.RowIslands.Add(childBigTicketDetails); if (e.Row.Level==0) { DataSet dsBigTicketD = new DataSet(); DataTable dtBTD; dtBTD = RegionalSalesSummary.GetBigTicketDetails(CurrentLoginAccess.UserID, strTradeType, strRegionCode, strTerritoryId); dtBTD.TableName = "BigTicketDetails"; dsBigTicketD.Tables.Add(dtBTD); dsBigTicketD.Tables["BigTicketDetails"].DefaultView.RowFilter = "[Fund/Manager]='" + e.Row.DataKey[1].ToString() + "' and [Rep Name]='" + repname + "'"; childBigTicketDetails.DataSource = dsBigTicketD; childBigTicketDetails.Level = e.Row.Level + 1; CreateField(childBigTicketDetails, "Account"); CreateField(childBigTicketDetails, "Class"); CreateField(childBigTicketDetails, "Amount"); CreateField(childBigTicketDetails, "Dummy"); childBigTicketDetails.InitializeRow += childBigTicketDetails_InitializeRow; childBigTicketDetails.CellSpacing = 1; childBigTicketDetails.BorderWidth = 1; //child.DataBind(); } } private void CreateField(ContainerGrid containerGrid, string fieldName) { BoundDataField field = new BoundDataField(true); field.Key = fieldName; field.DataFieldName = fieldName; field.Header.Text = fieldName; containerGrid.Columns.Add(field); }
protected void whdgBigTicket_InitializeRow(object sender, RowEventArgs e) { var gridrow = (ContainerGridRecord)e.Row; if (gridrow.Level <1) { gridrow.IsEmptyParent = true;
}
protected void childBigTicketDetails_InitializeRow(object sender, RowEventArgs e) { var gridrow = (ContainerGridRecord) e.Row; gridrow.Items[0].Column.Width = Unit.Pixel(100); gridrow.Items[1].Column.Header.Text = "Class"; gridrow.Items[1].Column.Width = Unit.Pixel(520); gridrow.Items[2].Column.Header.Text = "Amount"; gridrow.Items[2].Text = string.Format("{0:c}", decimal.Parse(gridrow.Items[2].Text)); gridrow.Items[2].Column.Width = Unit.Pixel(90); gridrow.Items[2].CssClass = "igalign"; gridrow.Items[3].Column.Header.Text = ""; } protected override void OnInit(EventArgs e) { base.OnInit(e); whdgBigTicket.InitializeRow += whdgBigTicket_InitializeRow;
whdgBigTicket.RowIslandsPopulating += new ContainerRowCancelEventHandler(whdgBigTicket_RowIslandsPopulating); DataSet dsBigTicket = new DataSet(); DataTable dtBT, dtBTD; dtBT = RegionalSalesSummary.GetBigTicket(); dtBT.TableName = "BigTicket"; dtBT.Columns.Add("Dummy"); dsBigTicket.Tables.Add(dtBT); dtBTD = RegionalSalesSummary.GetBigTicketDetails(); dtBTD.TableName = "BigTicketDetails"; dtBTD.Columns.Add("Dummy"); dsBigTicket.Tables.Add(dtBTD);
DataTable dtLevel0 = dsBigTicket.Tables[0]; DataTable dtLevel1 = dsBigTicket.Tables[1]; DataColumn[] ParentKeys = new DataColumn[2]; ParentKeys[0] = dtLevel0.Columns["id"]; ParentKeys[1] = dtLevel0.Columns["gh"];
DataColumn[] ChildKeys = new DataColumn[2]; ChildKeys[0] = dtLevel1.Columns["id"]; ChildKeys[1] = dtLevel1.Columns["gh"];
dsBigTicket.Relations.Add(ParentKeys, ChildKeys);
whdgBigTicket.DataSource = dsBigTicket; }
aspx
<ig:WebHierarchicalDataGrid ID="whdgBigTicket" DataKeyFields="id,gh" runat="server" AutoGenerateColumns="false" InitialExpandDepth="0" InitialDataBindDepth="0" BackColor="ActiveBorder" CellSpacing="1" > <Columns> <ig:BoundDataField DataFieldName="gh" Key="gh" Header-Text="gh" Width="125Px" Header-CssClass="ighand" CssClass="igoverflow"/> <ig:BoundDataField DataFieldName="Id" Key="Id" Header-Text="Id" Width="50Px" Header-CssClass="ighand"/> </Columns> <Behaviors> <ig:Sorting Enabled="true" SortingMode="Single"></ig:Sorting> <ig:ColumnResizing Enabled="true"/> <ig:Selection CellClickAction="Row" ></ig:Selection> </Behaviors> </ig:WebHierarchicalDataGrid>
kavitha