I have a need to use the WHDG with manual load on demand where the child band data source is a DataTable where the columns are dynamically created based on parameters. I think I need to create a TemplateDataField embedded with a WebImageButton dynamically based on the fields in the Table via the code and have it assigned to each column in the grid, so that each column displays to the user as a button that the user can select that item . I am new to the WHDG and not sure where to start. Are there any examples of this scenario or can someone help me get started?
Thanks
Hello John,
You can take a look at the following forum thread which is related to adding a template from the code behind - http://ko.infragistics.com/community/forums/p/66390/348918.aspx And we have also documentation regarding this - http://help.infragistics.com/Help/NetAdvantage/ASPNET/2012.1/CLR4.0/html/WebDataGrid_Using_Item_Template.html And also there is a page in our online help showing a snippet how to add band via manual load on demand - http://help.infragistics.com/Help/NetAdvantage/ASPNET/2012.1/CLR4.0/html/WebHierarchicalDataGrid_Load_On_Demand.html
Nikifor,
Thank you for your reply. I have seen the examples that you suggested and still don’t get how to create the TemplatedDataField for each columns on the child band when it’s dynamically loaded and the columns of the data source are dynamically created as well.
But, I was able to create the TemplatedDataField but not sure if it’s the correct way. I added an InitializeRow event to the ContainerGrid in the RowIsIandsPopulating event and then in the InitializeRow event I created a new Template and assigned it to the e.Row.Items Template. The buttons show on the child band for each column but I cannot click on any of them. They are acting as if they were ReadOnly.
void whdg1_RowIslandsPopulating(object sender, ContainerRowCancelEventArgs e)
{
e.Cancel = true;
Supplier sp = (((Infragistics.Web.UI.Framework.Data.ListNode)e.Row.DataItem)).Item as Supplier;
sp.Products = new List<Products>(NWindClient.GetProducts(Convert.ToInt32(sp.SupplierID)));
ContainerGrid child = new ContainerGrid();
child.Enabled = true;
child.Level = 1;
child.InitializeRow += new InitializeRowEventHandler(child_InitializeRow);
e.Row.RowIslands.Add(child);
child.DataSource = sp.Products;
}
void child_InitializeRow(object sender, RowEventArgs e)
for (int i = 0; i < e.Row.Items.Count; i++)
e.Row.Items[i].Template = new PlaceHolderTemplate(e.Row.Items[i].Text);