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 Stamen,
I have a hierarchical grid where I am facing issue for adding rows to child grid with existing rows. I tried your js that you recommended above. Its does insert the foreign key in ui.values,but when the transactions are posted, I dont see it. The "_addrow" function in infragistics.core.js is being hit before "iggridupdatingrowadding" function. So your js is not changing the actual transaction log due to which the inserted foreign key is not posted in transactions. Please advice.
Fantastic!!! that is a good new. Thank you so much for listening to customers :)
Hello Luis,
I am glad I was able to help! We are also determined to get this implemented in the code so you don't need to have some records in the children data sources to enable foreign key resolution. I have logged this as a work item in our internal tracking system with a Development ID of 185386. A support case is created on your behalf with number CAS-146925-F2J0Z4 , so that you can be notified when it is resolved.You can find your active cases under Account - Support Activity in our website. Select your ticket and go to Development Issues tab.
Once you get the service release containing the fix you will no longer need this workaround.
Thank you for using Infragistics forums!
Best regards,
Stamen Stoychev
THANK YOU SO MUCH! :)
It just works beautifully!!! I hope you add this functionality out of the box, this is very important when you are doing batch updating. Fortunately I am using negative numbers for primary and foreign keys for new rows in the grid, so that makes things simpler. In the server I change those negative numbers for real keys (actually the database does it). Thank you good man :)
The reason the foreign key is not automatically set for this case is that the data source of the child grid contains no records initially. Updating can only check for the foreign key within the records it sees and at the moment there is no communication built-in for the feature to ask parents for this information. We'll discuss internally whether or not such functionality should be implemented so we can cover the use-case. If such decision is made I'll create an internal work item and link it to the case created for this forums post. In this way you'll get notified once the implementation is available.
In the meantime you can use the workaround I've prepared. The idea behind it is to use the id of the child grid to extract the foreign key from it. It's not the cleanest solution but it's the shortest one by far, any other requiring traversing the hierarchical structure and identifying whose child the grid throwing the event is. The extracted key is then added to the row object "rowAdding" passes as an event argument. To keep the event binding consistent with your other code it would look something like this:
$(document).delegate("#grid1", "iggridupdatingrowadding", function (evt, ui) { var id = ui.owner.grid.id(), match = id.match(/_([-0-9]*)_/), fk = match && match.length === 2 ? parseInt(match[1], 10) : null; if (fk !== null && ui.owner.grid.options.foreignKey) { ui.values[ui.owner.grid.options.foreignKey] = fk; } });
Please, have in mind that the regex used may need to be modified if you are using anything other than numbers (positive or negative) as PKs. You'll have to ensure it works properly for your hierarchical grid.
I am attaching my sample for reference. I hope this helps! Please, let me know if you have any other questions and/or concerns!