Hi,
I have added the two child records in first parent and two child records in second parent. HOw do I get all these pending transactions of child grids in one submit click.
Thanks
Ramesh D
Hi Ramesh,
I am not sure what you are trying to achieve exactly - get the pending transactions on the client or you would like to process the transactions on the server?
On the client, you can get those by:
var hierarchicalGridChildren = $("#hierarchicalGrid").igHierarchicalGrid("allChildren");
var transactions = hierarchicalGridChildren.igGrid("pendingTransactions");
On the server:
[ActionName("EditingSaveChanges")] public ActionResult EditingSaveChanges() { ViewData["GenerateCompactJSONResponse"] = false; GridModel m = new GridModel(); List<Transaction<Category>> categoryTransactions = m.LoadTransactions<Category>(HttpContext.Request.Form["ig_transactions"]); foreach (Transaction<Category> t in categoryTransactions) { DataRow dr = this.CategoriesProducts.Tables["Categories"].Rows.Find(Int32.Parse(t.rowId)); if ((t.layoutKey == null) && (dr != null)) { if (t.type == "row") { Category categoryRow = (Category)t.row; if (categoryRow.CategoryName != null) { dr["CategoryName"] = categoryRow.CategoryName; } if (categoryRow.Description != null){ dr["Description"] = categoryRow.Description; } } else if (t.type == "deleterow") { this.CategoriesProducts.Tables["Categories"].Rows.Remove(dr); } } } List<Transaction<Product>> productTransactions = m.LoadTransactions<Product>(HttpContext.Request.Form["ig_transactions"]); foreach (Transaction<Product> t in productTransactions) { DataRow dr = this.CategoriesProducts.Tables["Products"].Rows.Find(Int32.Parse(t.rowId)); if ((t.layoutKey == "Products") && (dr != null)) { if (t.type == "deleterow") { this.CategoriesProducts.Tables["Products"].Rows.Remove(dr); } else if (t.type == "row") { Product productRow = (Product)t.row; if (productRow.ProductName != null) { dr["ProductName"] = productRow.ProductName; } if (productRow.CategoryID != null) { dr["CategoryID"] = productRow.CategoryID; } if (productRow.UnitPrice != null) { dr["UnitPrice"] = productRow.UnitPrice; } if (productRow.UnitsInStock != null) { dr["UnitsInStock"] = productRow.UnitsInStock; } dr["Discontinued"] = productRow.Discontinued; } } } JsonResult result = new JsonResult(); Dictionary<string, bool> response = new Dictionary<string, bool>(); response.Add("Success", true); result.Data = response; return result; }
You can refer to:
http://www.igniteui.com/hierarchical-grid/editing-dataset.
Does the above help you?
If I do the multiple transactions in child grid at a time, it is retuning only one transaction row. If I add the two child rows to one parent , it is working as expected.
If I add one child row for one parent and other child row for other parent, it is returning only one child row in pending tranactions. I used the below code. Please provide your inputs
var hierarchicalGridChildren = $("#gridNotes").igHierarchicalGrid("allChildren");
var childGridNotesTransactions = JSON.stringify(hierarchicalGridChildren.igGrid("pendingTransactions"));
Do you mean that you make two changes in a child grid and you get only one transaction? Are you sure that you are not commiting anything before the second change?
I tried this and it worked fine as you can see in the attached sample.
Please review it and let me know if that's not what you are doing.
Hello,
I am checking about the progress of this issue. Please let me know If you need any further assistance on this.