Hi,
I have a hierarchical grid that I am binding to a dataset. One table is summary data and the second table is the detail data. I have definied a relation using a field called ExpenditureType. I am building all of my columns dynamically. All works well, but my details table displays twice when I expand. The code is pretty simple, so I can't figure out what is causing it. I have attached a screenshot as well. Do you see what I am doing wrong?
Thanks! Tami
I have a hierarchical grid that I am binding to a dataset. One table is summary data and the second table is the detail data. I have definied a relation using a field called ExpenditureType. I am building all of my columns dynamically. All works well, but my details table displays twice when I expand. The code is pretty simple, so I can't figure out what is causing it. I have attached a screenshot as well. Do you see what I am doing wrong?
Thanks! Tami
private void BindGrid() { RadGrid1.DataSource = _dsBudgetVerification.Tables["BVSummary"]; RadGrid1.Width = Unit.Percentage(98); RadGrid1.AutoGenerateColumns = false; RadGrid1.GridLines = GridLines.Both; //TODO: This doesn't seem to work RadGrid1.CssClass="gridborder"; RadGrid1.MasterTableView.DataKeyNames = new string[] { "ExpenditureType" }; RadGrid1.MasterTableView.Name = "tvSummary"; RadGrid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.ServerBind; //RadGrid1.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client; //RadGrid1.ClientSettings.AllowExpandCollapse = true; //Add Summary table RadGrid1.MasterTableView.Width = Unit.Percentage(100); GridBoundColumn boundColumn; GridDropDownColumn ddlColumn; foreach (DataColumn dataColumn in _dsBudgetVerification.Tables["BVSummary"].Columns) { //these apply to every column in Summary boundColumn = new GridBoundColumn(); RadGrid1.MasterTableView.Columns.Add(boundColumn); boundColumn.HeaderText = dataColumn.Caption; boundColumn.HeaderStyle.CssClass = "gridheader"; //we know the column names of the text fields, so let's set their formatting switch (dataColumn.Caption) { case "EscalatorID": case "EscalatorName": { //TODO: figure out how to add combobox here boundColumn.DataField = dataColumn.Caption; break; } case "ExpenditureType": case "ExpenditureTypeExists": { boundColumn.DataField = dataColumn.Caption; if (dataColumn.Caption == "ExpenditureTypeExists") boundColumn.Visible = false; break; } default: //anything else will be an amount { boundColumn.DataField = dataColumn.Caption; boundColumn.HeaderStyle.Width = 50; //also build our list of months for use in the Total column lstMonths += '"' + dataColumn.ColumnName + '"' + ','; break; } } } //now trim the last comma off the list lstMonths = lstMonths.Substring(1, lstMonths.Length - 3); //now add a calculated Total column at the end of the summary CreateCalcColumn(RadGrid1.MasterTableView, lstMonths); //Add Details table GridTableView tableViewDetails = new GridTableView(RadGrid1); RadGrid1.MasterTableView.DetailTables.Add(tableViewDetails); tableViewDetails.Width = Unit.Percentage(100); tableViewDetails.DataSource = _dsBudgetVerification.Tables["BVDetails"]; tableViewDetails.DataMember = "BVDetails"; tableViewDetails.DataKeyNames = new string[] { "ExpenditureType" }; tableViewDetails.Name = "tvDetails"; GridRelationFields relationFields = new GridRelationFields(); relationFields.MasterKeyField = "ExpenditureType"; relationFields.DetailKeyField = "ExpenditureType"; tableViewDetails.ParentTableRelation.Add(relationFields); RadGrid1.MasterTableView.DetailTables.Add(tableViewDetails); foreach (DataColumn dataColumn in _dsBudgetVerification.Tables["BVDetails"].Columns) { switch (dataColumn.Caption) { case "EscalatorID": case "EscalatorName": { //ddlColumn = new GridDropDownColumn(); //tableViewDetails.Columns.Add(ddlColumn); //ddlColumn.UniqueName = "Escalator"; //ddlColumn.ListTextField = "Escalator"; //ddlColumn.ListValueField = "EscalatorID"; //ddlColumn.ListDataMember = "Escalator"; //ddlColumn.DataSourceID = "dsrcEscalators"; //ddlColumn.DataField = dataColumn.Caption; //ddlColumn.HeaderText = dataColumn.Caption; //ddlColumn.HeaderStyle.CssClass = "gridheader"; //ddlColumn.EditItemTemplate = new ddlTemplate(); break; } default: { boundColumn = new GridBoundColumn(); tableViewDetails.Columns.Add(boundColumn); boundColumn.DataField = dataColumn.Caption; boundColumn.HeaderText = dataColumn.Caption; boundColumn.HeaderStyle.CssClass = "gridheader"; break; } } } //now add a calculated Total column at the end of the details CreateCalcColumn(tableViewDetails, lstMonths); } <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="RadGrid1"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"> </telerik:RadAjaxLoadingPanel> <telerik:RadGrid ID="RadGrid1" runat="server" OnItemDataBound="RadGrid1_ItemDataBound" />