Hi,
I am trying to add a RadGrid to GridTemplateColumn in GridTableView . But it doesn't show up. Below is the code snippet. Am I missing something.
Thanks,
Gijo Joseph.
| GridTableView tableView = new GridTableView(radGrid1); |
| if (lastAddedDetailTable.ID == "RadGrid1") |
| { |
| radGrid1.MasterTableView.DetailTables.Add(tableView); |
| } |
| else |
| { |
| ((GridTableView)lastAddedDetailTable).DetailTables.Add(tableView); |
| } |
| //tableView.ItemsCreated += new GridItemEventHandler(radGrid1_ItemCreated); |
| //tableView.Width = Unit.Percentage(100); |
| //tableView.Font.Bold = true; |
| //tableView.BorderWidth = 2; |
| //tableView.BorderColor = System.Drawing.Color.Red; |
| if (filterElement.Attribute("parameters") != null) |
| tableView.Name = filterElement.Attribute("parameters").Value; |
| if (filterElement.Attribute("dataKeyNames") != null) |
| tableView.DataKeyNames = filterElement.Attribute("dataKeyNames").Value.Split(','); |
| string[] columnNames = filterElement.Attribute("columns").Value.ToString().Split(','); |
| foreach (string columnName in columnNames) |
| { |
| GridBoundColumn boundColumn = new GridBoundColumn(); |
| tableView.Columns.Add(boundColumn); |
| colName = columnName; |
| if (colName.Contains("[F]")) |
| { |
| boundColumn.Visible = false; |
| colNamecolName = colName.Substring(0, colName.IndexOf("[F]")); |
| } |
| boundColumn.UniqueName = colName; |
| boundColumn.DataField = colName; |
| boundColumn.HeaderText = colName; |
| boundColumn.HeaderStyle.Font.Bold = true; |
| } |
| GridTemplateColumn templateColumn = new GridTemplateColumn(); |
| tableView.Columns.Add(templateColumn); |
| templateColumn.ItemTemplate = new GridTemplate(filterElement.Attribute("name").Value); |
| using System; |
| using System.Collections.Generic; |
| using System.Linq; |
| using System.Text; |
| using System.Web.UI; |
| using Telerik.Web.UI; |
| namespace Data.Reports |
| { |
| public class GridTemplate : ITemplate |
| { |
| protected RadGrid childGrid; |
| private string colName; |
| public GridTemplate(string cName) |
| { |
| colName = cName; |
| } |
| public void InstantiateIn(System.Web.UI.Control container) |
| { |
| childGrid = new RadGrid(); |
| childGrid.ID = colName; |
| //childGrid.NeedDataSource +=new GridNeedDataSourceEventHandler(childGrid_NeedDataSource); |
| childGrid.DataSource = DBClass.GetDataSP(Grid.referencePath, null); |
| container.Controls.Add(childGrid); |
| } |
| public void childGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
| { |
| childGrid.DataSource = DBClass.GetDataSP(Grid.referencePath, null); |
| } |
| } |
| } |