Hello and thanks for your time:
I'm working with the WebHierarchicalDataGrid with a mix of bounddatafields and a templatedatafield that includes a button. The functionality I'm aiming for is for the user to be able to click the button and having the event fire which will then make changes to the database from which the grid is bound, then have the grid reflect these changes that the button caused. I currently have the events and the database changes working, the issue I've come across is the Grid is not reflecting the changes made from the button event.
I wrote up an example and in this there are a list of ID's, a bool, and the button that should set the bool to false in the database, only true entries should be shown in the grid. Clicking the button does indeed update the database, but the entry still exists on the Grid till you cause it to rebind with a sort or page change.
<div id="divMembers" runat="server"> <x2Vol:Members ID="x2vMembers" runat="server" /> <igwhdg:WebHierarchicalDataGrid ID="whdgTest" runat="server" StyleSetName="Claymation" EnableAjax="true" DataKeyFields="VolunteerID" DefaultColumnWidth="" Width="98%" Key="TestGrid" OnInitializeRow="whdgTest_InitializeRow" AutoGenerateBands=false AutoGenerateColumns=false > <Behaviors> <igwhdg:Sorting SortingMode=Single Enabled=true> </igwhdg:Sorting> </Behaviors> <Columns> <igwhdg:BoundDataField Key="volID" DataFieldName="VolunteerID"> <Header Text="VolID" /> </igwhdg:BoundDataField> <igwhdg:BoundDataField Key="IsApproved" DataFieldName="IsApproved"> <Header Text="Bool" /> </igwhdg:BoundDataField> <igwhdg:TemplateDataField Key="button" > <Header Text="Button" /> <ItemTemplate> <asp:Button ID="buttonClicker" runat="server" /> </ItemTemplate> </igwhdg:TemplateDataField> </Columns> </igwhdg:WebHierarchicalDataGrid></div>
Code Behind:
protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); Infragistics.Web.UI.DataSourceControls.DataView volView = new Infragistics.Web.UI.DataSourceControls.DataView(); VolunteerOrgCollection volColl = new VolunteerOrgCollection(); volColl.LoadAll(); volColl.Filter = "IsApproved = 1"; WebHierarchicalDataSource thisWHDS = new WebHierarchicalDataSource(); volView.DataSource = volColl; volView.ID = "volView"; thisWHDS.DataViews.Add(volView); whdgTest.DataSource = thisWHDS; whdgTest.DataMember = volView.ID; whdgTest.DataBind(); whdgTest.GridView.ItemCommand += new ItemCommandEventHandler(whdgTest_ItemCommand); } protected void whdgTest_ItemCommand(object sender, HandleCommandEventArgs e) { if (e.CommandName == "Clicker") { VolunteerOrg thisEntry = new VolunteerOrg(); thisEntry.LoadByPrimaryKey(int.Parse(e.CommandArgument.ToString())); thisEntry.IsApproved = false; thisEntry.Save(); Page_Load(null, null); } } protected void whdgTest_InitializeRow(object sender, RowEventArgs e) { WebHierarchyData whdVol = (WebHierarchyData)e.Row.DataItem; VolunteerOrg thisVolO = (VolunteerOrg)whdVol.Item; Button buttonClicker = (Button)e.Row.Items[whdgTest.Columns["button"].Index].FindControl("buttonClicker"); buttonClicker.CommandName = "Clicker"; buttonClicker.CommandArgument = thisVolO.MemberID.Value.ToString(); }
It feels as if the Grid is one step behind and this is causing issues when the user then clicks another cell's button, it ends up *not* being the cell they clicked on but another row's instead as it appears the data is correct behind the grid, but the actual display is not updated.
Is there a way for the grid to be forced to redisplay? Or a better way to handle events to prevent this?
Hi,
I am convinced that the template fields have not been worked out all the way in the WHDG. The events are not exposed, you can't edit templates from the smarttag, and I've seen my controls in a template column just not show up in parent bands.
It would be reassuring if one of the big guys would comment on this issue.
Ed
I'm also convinced that template fields are not working out in WHDG. I have a WebImage button on a parent row, the only way that I can get smart tags to work is build the WebImage button out of the grid, using smart tags then move the one that I have built back to the template area. It seems much better to just use a regular image button tag rather than trying to us Infragistics WebImage button if you are going to use a button within the grid.
I hope to be corrected on the above about using a regular stock image button rather than an Infragistics WebImage button.
Thanks,
Keith Black
On I can be corrected!!! You can use Smart tag on a template item. Just use smart tag on the WHDG first then select Template item. BANG you get the smart tag for the button!!!
EDITING works on a WebImage button within WHGD, but does not fire off the click client event.