What is the right way to set a two level igHierarchicalGrid for batch updating and get its aggregated transactions in the client?
In the attached example (inspired on some code found in this forum) the grid let the user to add, modify and delete rows from level 1 (categories) and level 2 (products). For simplicity in this example I am not catching deleted rows. The problem is that I can't get transactions from level 2. Also, in order to add rows at level 2 AutoCommit must be set to true (when parent row is new) , this is an issue because a) I cant use aggregated transactions (according to documentation: This option takes effect only when autoCommit is set to false), that means bigger packets sent to the server, b) italics applied to edited rows are lost so user can't see what has been edited. Is there a way to fix this?
Hi Petar, thank you for your help. Now I am able to get child transactions. I did other testing to see what happens:
var hierarchicalGridChildren = $("#MyGrid").igHierarchicalGrid("allChildren");
var transLevel4 = hierarchicalGridChildren.igGrid("transactionsAsString"); var transLevel3 = JSON.stringify(hierarchicalGridChildren.igGrid("pendingTransactions")); var transLevel2 = JSON.stringify(hierarchicalGridChildren.igGrid("allTransactions")); var transLevel1 = JSON.stringify($("#MyGrid").igGrid("allTransactions"));
I modified rowId 1, added rowId 5, and deleted rowId 4. Look the result of this at the image below (debug).
As you can see transLevel4 and transLevel2 have the same result (in this case transLevel4 and transLevel3 has nothing to do with the real level in the grid, it is just a name). Now I realize why transLevel3 is empty: there are no pending transactions because I am using AutoCommit(true). transLevel1 is empty because I didn't edit any parent row. Another interesting thing is that using stringify or transactionsAsString has the same effect. (Question 1) Does transactionsAsString use stringify behind the scene?
Regarding to iggridupdatingrowadded I have an issue: setting AutoCommit(false), new child rows are lost after pressing enter on the new row.
(Question 2) How to fix that?
And one more thing. I realized that new child rows inherit the parent's Id if the parent is not new, but when you add a new parent their children don't inherit the parent's Id. (Question 3) How to get the parent's Id and set the child's foreignkey?
Hello Luis,
The transactions for the child bands can be accessing through each respective child layout. For instance, to get the current transactions of the first child grid, something similar to the following may be used:
$($("#MyGrid").igHierarchicalGrid("allChildren")[0]).igGrid("allTransactions")
In order to retain aggregate transactions and respectively, disabled AutoCommit on the root layout, I would suggest handling the rowAdded event and invoking commit manually:
//Bind after initialization $(document).delegate("#MyGrid", "iggridupdatingrowadded", function (evt, ui) {
$("#MyGrid").igGrid("commit"); });
Hope this helps. Please feel free to contact me if you have any questions.