Iam trying to include the add,edit and delete functionality using the CommandItemItemplate to all the Details Table view in a hierachial grid.
SO I create the CommandItemTemplate class extending from ITemplate and set the commandItemTemplate property during the creation of each level.
But Iam not able to see the CommandItemTemplate on the child table grids..
Only the one set during design tiimje for mastertableview is visisble.
Below is the code with jsut the Delete Command
private
class ProductCommandItemTemplate : ITemplate
{
protected LinkButton deleteButton;
public ProductCommandItemTemplate()
{
deleteButton =
new LinkButton();
}
public void InstantiateIn(Control container)
{
deleteButton =
new LinkButton();
deleteButton.ID =
"deleteButton";
deleteButton.Text =
"Delete record";
deleteButton.CommandName =
"InitDelete";
container.Controls.Add(deleteButton);
}
}
private
void CreateHierarchyTableTemplates(int noOfLevels)
{
GridTableView parentTableView = radGridProducts.MasterTableView;
parentTableView.DetailTables.Clear();
for (int i = 0; i < noOfLevels; i++)
{
GridTableView newParentTableView = CreateProductChildGrid(parentTableView);
parentTableView = newParentTableView;
}
}
private GridTableView CreateProductChildGrid(GridTableView parentGridTableView)
{
GridTableView tableViewChildProduct = new GridTableView(radGridProducts);
parentGridTableView.DetailTables.Add(tableViewChildProduct);
tableViewChildProduct.DataSource =
new List<InstrProduct>();
AddProductChildGridAttributes(tableViewChildProduct);
tableViewChildProduct.EnableColumnsViewState =
true;
return tableViewChildProduct;
}
private void AddProductChildGridAttributes(GridTableView tableViewChildProduct)
{
tableViewChildProduct.PageSize = 100;
tableViewChildProduct.Width =
Unit.Percentage(100);
tableViewChildProduct.SkinID =
"Office2007";
tableViewChildProduct.AutoGenerateColumns =
false;
tableViewChildProduct.AllowPaging =
true;
tableViewChildProduct.EnableViewState =
true;
tableViewChildProduct.HierarchyLoadMode =
GridChildLoadMode.ServerOnDemand;
tableViewChildProduct.BorderColor =
Color.Blue;
tableViewChildProduct.PagerStyle.AlwaysVisible =
true;
tableViewChildProduct.PagerStyle.Position =
GridPagerPosition.TopAndBottom;
AddProductChildGridBoundColumns(tableViewChildProduct);
tableViewChildProduct.EnableColumnsViewState =
true;
tableViewChildProduct.AllowAutomaticDeletes =
true;
tableViewChildProduct.CommandItemTemplate =
new ProductCommandItemTemplate();
}
private void AddProductChildGridBoundColumns(GridTableView tableViewChildProduct)
{
GridClientDeleteColumn col1 = new GridClientDeleteColumn();
tableViewChildProduct.Columns.Add(col1);
col1.ConfirmText =
"Delete this product?";
col1.ButtonType =
GridButtonColumnType.ImageButton;
col1.ImageUrl =
"../images/Delete.gif";
col1.CommandName =
"Delete";
col1.UniqueName =
"DeleteColumn";
GridClientSelectColumn col2 = new GridClientSelectColumn();
tableViewChildProduct.Columns.Add(col2);
GridBoundColumn col3 = new GridBoundColumn();
tableViewChildProduct.Columns.Add(col3);
col3.DataField =
"Tag";
col3.UniqueName = tableViewChildProduct.Name +
"_colTag";
col3.HeaderText =
"Tag";
GridBoundColumn col4 = new GridBoundColumn();
tableViewChildProduct.Columns.Add(col4);
col4.DataField =
"ShortDescription";
col4.UniqueName = tableViewChildProduct.Name +
"_colShortDescription";
col4.HeaderText =
"Short Description";
GridBoundColumn col5 = new GridBoundColumn();
tableViewChildProduct.Columns.Add(col5);
col5.DataField =
"LongDescription";
col5.UniqueName = tableViewChildProduct.Name +
"_colLongDescription";
col5.HeaderText =
"Long Description";
GridHyperLinkColumn col6 = new GridHyperLinkColumn();
tableViewChildProduct.Columns.Add(col6);
col6.UniqueName = tableViewChildProduct.Name +
"_colCharacteristics2";
col6.HeaderText =
"Characteristics";
col6.DataNavigateUrlFormatString =
"javascript:ShowEditForm('{0}');";
col6.DataNavigateUrlFields =
new string[] { "Id" };
col6.Text =
"View";
}
protected
void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
int noOfproductLevels = _presenter.GetNoOfProductLevels();
radGridProducts.MasterTableView.Width =
Unit.Percentage(100);
radGridProducts.MasterTableView.DataKeyNames =
new String[] { "Tag", "ParentTag", "Id" };
CreateHierarchyTableTemplates(noOfproductLevels);
}
}
We just create the child tables dynamically