Hello mcseidel ,
I apologize about the delayed answer.
Adding additional elements after the container grid is not supported out of the box. Making changes to the child grid however will trigger updating events like it does for the parent grid.
So in that event you can update the data source of the grid. As for triggering a call to the server. If you have activation behavior enabled the updating will trigger on every cell value changing after you change the active cell. Otherwise if you’ve enabled batch updating any page postback will trigger the updating event.
For editing of only some of the cells you’ll need to enable editing behavior for the child band (container grid you created) and set the EditingColumnSettings correspondingly with ReadOnly to true for the columns that should not be editable and ReadOnly to false for the ones that should be editable.
Please refer to the attached sample and let me know if you have any further questions.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
Thanks, that was helpful. I'm moving in the same direction of setting individual behaviors on the instance of the child grid and might ask couple of questions withing this post framework later.
You can register the client side event from the CellEditingBehavior for the child grid like this:
childGrid.Behaviors.EditingCore.Behaviors.CellEditing.CellEditingClientEvents.EnteringEditMode = "WHDGChildGrid_CellEditing_EnteringEditMode";
When you register it like this for the child grid the event will trigger only when you enter edit mode in the child grid.
Regarding the value of the current cell you can get it with:
eventArgs.getCell().get_text()
This will return the content of the current cell.
For example if you modify the previous code like this:
function WHDGChildGrid_CellEditing_EnteringEditMode(sender, eventArgs) {
if (eventArgs.getCell().get_text() == "Item 1") {
eventArgs.set_cancel(true);
}
Then only the cell with text “Item 1” will be read-only. Please refer to the modified sample and let me know if you have any questions.
Hi Maya, you were very helpful and all the sample were to the point, I'll check that latest a bit later, but I want get back for a brief moment to something that took me about the full day to find out :
As I mention somewhere earlier that when I'm adding CellEdit behavior to the child grid the same way you are in you projects somehow it does not work. Sort funny enough I can break your projects now too, all it needs to switch this two lines :
e.Row.RowIslands.Add(childGrid); //We disable the autogenerated columns and create the columns so that we can have access to them in the columns collection childGrid.AutoGenerateColumns = false;
i.e. if childGrid.AutoGenerateColumns = false; executed on existing object first, before adding it to the rowIsland "Celledit" behavior not going to work on the child grid.
This note is to share the solution to the strange problem and also you might know why it happening. It does not look intuitive...
Thanks.
I recall coming across this issue before. I appologize for not noticing it.
The child grid needs to be added to the RowIsland collection before any properties are set on it. Setting the properties triggers creation of other objects and since the child grid is not part of the rowIslands collection yet it does not have a reference to the page and cannot create these object properly.
So make sure that you first add the childgrid to the rowislands collection and then make any additional changes to it.
Let me know if you have any further questions regarding this.
I need to enable postback on the loaded on demand child grid. There is RowUpdating event, how I can added to child grid without triggering same event on parent grid. Further, I actually need it to get triggered rather on cell updating so I can process it on the server side. Can I instead of RowUpdating use cellSelectionChanged and process in on the server and raise this event ( and process it) only from the child grid ? Anyway what would be most efficient approach to process change of the value in the child grid cell on the server.Thanks.
Hello mcseidel,
On the client side you can manually trigger the ajax call to the serever by invoking the commit method. For example in the CellSelectionChanged client side event you can do the following:
function WebHierarchicalDataGrid1_Selection_CellSelectionChanged(sender, eventArgs)
{
///<param name="sender" type="Infragistics.Web.UI.WebHierarchicalDataGrid"></param>
///<param name="eventArgs" type="Infragistics.Web.UI.CellSelectionChangedEventArgs"></param>
sender.get_behaviors().get_editingCore().commit()
Regarding the events for the child grid. You can register them in the following way:
childGrid.InitializeRow += new InitializeRowEventHandler(childGrid_InitializeRow);
They should trigger events associated only with the current container grid.
I’ve noticed however that this doesn’t seem to behave as expected for the RowUpdating event.
I’ll log this issue to be reviewed by our development team. I’ll contact you with the development issue number so that you may track it’s progress.
Updating Main Grid.Maya, I looked at you sample and it does updates the main grid value as expected. But my scenario is different. I have problem updating main grid right after changes done to child grid in RowUpdating event. If event triggered by main grid then it is not a problem e.g. after line mr.Amount = 95000; executed I can see changes on the main grid, if I try to do the same in the child grid section of the same event it’s not working even if I DataBind main grid again. This is the place where mr.Amount = 35000; got executed. The issue that I do not know how to address is the following : MainGris get binded on the PageLoad that executed before RowUpdating event, so when value in the master source changed ( mr.Amount = 35000) it could be seen only on the next postback (after any other child grid get expanded). So somehow if the change occured in main grid and new value assign to underline source (mr.Amount = 95000) then changes can be seen, if event triggered by child grid then changes to main grid ( mr.Amount = 35000) can be seen only after another postback. Can you advise how to make mr.Amount = 35000 visible without postback.Project attachedThanks.
Make sure that you make the changes for the parent grid directly to the WebHierachicalDataGrid instance. Otherwise the approach is the same.
I tested it by setting a value of 1 to the first row’s Amount column and it got recalculated and persisted as expected.
You can get the summary result from the SummaryCalculated event from the event args:
protected void whdg_SummaryCalculated(object sender, SummaryEventArgs e)
var value = e.SummaryValue;
You can’t directly access it fromthe behavior.
Please refer to the attached sample and let me know if you have any questions.
The RequestFullAsyncRender did the job to persist updating the child grid I’m also trying to update parent grid with the child’s total amount value and need some help to sequence events :In the whdg_RowUpdating if I would add to your sample the following : islandType3Tbl.Rows[0][4] = 1300; then amount column get updated and persisted, and custom sum get recalculated, so it works perfect... now I’m trying to get this recalculated summary value and put it into the parent row, something like : ExhibitLR2MasterDS mDS = (ExhibitLR2MasterDS)Session["data"]; mDS.MasterTable.Rows[1][4] = 1201;where 1201 is the summary for the amount field in the child grid. Can you help me with the following :1. On the server side how to access summary value , seems like something as grid.Behaviors.SummaryRow...?? but what exactly ?2. What to do with parent grid right within whdg_RowUpdating so the parent row also would show new value and parent grid total get recalculated. I tried to do the same as for child grid ( clear datasource, get new one, etc. ) and it did not work. Can you advise and/or maybe update the your version of the site : whdg_LoadOnDemandEdit01_Modified.zip
Over updating and other postbacks you should not recreate the rowisland if it’s already created. So make sure that when you update a row that you make a check whether a rowisland already exists in the RowIslandsPopulating event. Also make sure that you set the data source in the RowUpdating event and databind. Also you may have to invoke the RequestFullAsyncRender() method for the changes to be reflected on the client.
Please refer to the attached working sample. In it I change the description of the first child row to “Value” and the change gets persisted.
Maya, this dynamic grid does not go easy on me ..Here the problem :I modified sample as following in order to have edited values on screen: in Page_Load I’ve stored DS into session // store original dataset in session if (!IsPostBack) {…...................................... // store original dataset in session Session.Remove("LR2MasterDS"); Session["LR2MasterDS"] = MasterDS; Session.Remove("LR2DetailsDS"); Session["LR2DetailsDS"] = DetailsDS; whdg.DataSource = MasterDS; whdg.DataBind(); } else whdg.DataSource = (ExhibitLR2MasterDS)Session["LR2MasterDS"]; in the whdg_RowIslandsPopulating - get the datasource from session :
ExhibitLR2DetalsDS DetailsDS = (ExhibitLR2DetalsDS)Session["LR2DetailsDS"];ExhibitLR2DetalsDS.type3tblDataTable islandType3Tbl = DetailsDS.type3tbl;when it gets bind It uses datasource updated in the new added RowUpdating IslandGrid.DataSource = islandType3Tbl;IslandGrid.DataBind();protected void whdg_RowUpdating(object sender, RowUpdatingEventArgs e) { GridRecord gr = e.Row; ContainerGrid g = (ContainerGrid)sender; ControlDataField a = g.FindColumn("idLR5Detail"); if (a != null) { int idMaster = (int) e.Values["idMaster"]; int idRec = (int) e.Values["idRec"]; int newAmnt = (int) e.Values["Amount"]; int oldAmnt = (int)e.OldValues["Amount"]; int nType = (int) e.Values["Ntype"]; int dfrnce = (newAmnt - oldAmnt) * ((nType == 1) ? 1 : -1); ExhibitLR2DetalsDS DetailsDS = (ExhibitLR2DetalsDS)Session["LR2DetailsDS"]; ExhibitLR2MasterDS MasterDS = (ExhibitLR2MasterDS)Session["LR2MasterDS"]; ExhibitLR2DetalsDS.type3tblRow dr = DetailsDS.type3tbl.FindByidRec(idRec); dr.Amount = newAmnt; ExhibitLR2MasterDS.MasterTableRow mr = MasterDS.MasterTable.FindByidMaster(idMaster); mr.Amount = mr.Amount + dfrnce; Session["LR2DetailsDS"] = DetailsDS; Session["LR2MasterDS"] = MasterDS; whdg.DataSource = MasterDS; whdg.DataBind(); } else { ExhibitLR2MasterDS MasterDS = (ExhibitLR2MasterDS)Session["LR2MasterDS"]; int idMaster = (int)e.Values["idMaster"]; int newAmnt = (int)e.Values["Amount"]; ExhibitLR2MasterDS.MasterTableRow mr = MasterDS.MasterTable.FindByidMaster(idMaster); mr.Amount = newAmnt ; Session["LR2MasterDS"] = MasterDS; whdg.DataSource = MasterDS; whdg.DataBind(); }Here is the problem : After row updated it is posting back and after page_load comes to RowUpdating where Datasources get midfield. Parent grid get databind and then it goes to RowIslandsPopulating where it retrieves the updated DetailsDS from session and does DataBind at the end. I’m checking in debugger contents of islandGrid.DataSource = islandType3Tbl; table right before next line ( islandGrid.DataBind(); ) and it is updated table with new values, but in the browser it shows old value. Also the value of the parent grid datasource get modified and it is also reflected in Datasource (MasterDS.MasterDStbl) but old value still shows up. Is it get cashed somewhere ? How I can turn it off ? When the same done to parent grid it goes through the same path, just different branch of RowUpdating and value in browser is new, means it works properly....