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://es.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);
Hello John,Please take a look at the attached sample which is displaying the buttons as expected and they are making a postback everytime i click one of them.
Thank you for your reply. Your example works. But, if you replace the Button with the WebImageButton it does not work.
Also, if I add a click event to the button in your example, the event is not being fired on the post back.
I have investigated your issue “WebImageButton does not respond to client side interactions when it’s in an item template in child band.”, and I have asked our engineering staff to examine this further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of 123955. The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution.
I will leave this case open and update you with any new information after the review. You can also continue to send updates to this case at any time.
You can view the status of the development issue connected to this case by selecting the "Development Issues" tab when viewing this case on the web site.
Please let me know if you need more information.
Thank you for all your support. Let me know if you need any more information from me on this topic.
John
Hello John,Please let me know if you have any further questions regarding this issue.
Hello John,I assume your code at the moment looks like the attached sample. If so then take a look that the item template is reinstantiated on every postback which means that the button is cleared after it makes the postback so this is causing the not firing of the event. I would suggest to try handling the client side click event which should be fired and then make a __doPostBack with some appropriate arguments through it. I have not tested this suggestion but it’s the only one I can came up at the moment.
Thank you for your reply. That seem to work on the WebImageButton, I now can click on the image. However, I am still unable to get the button click event to fire.
public class CustomItemTemplate : ITemplate
#region ITemplate Members
public void InstantiateIn(Control container)
WebImageButton Btn = new WebImageButton();
Btn.Text = "MyTmpBtn";
Btn.Click += new ClickHandler(Btn_Click);
container.Controls.Add(Btn);
void Btn_Click(object sender, ButtonEventArgs e)
//not getting here on the button click
throw new NotImplementedException();
#endregion
Hello John,This behavior occurs as not a bug. When a script control is used in the template with ajax, it does render and call the start up script to initialize the client objects. So the image buttons are not fully functional. If ajax is OFF, then the whole page is rerendered, including the new init scripts. This is what needs to be done.