Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
290
Getting the pending transactions in igHierarchicalGrid of child grids
posted

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

Parents
  • 71886
    Suggested Answer
    Offline posted

    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?

Reply Children