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
55
is it possible to get grid ID that called SaveChanges when handling grid updates in MVC?
posted

Hello - I have a solution using Asp MVC with multiple igGrids on a single page.  I am following the documentation and am getting transactions to come into my controller page when the user pushes a button that fires the SaveChanges call.  .  However, I don't get anything in the response that gives me indication on which grid / grid ID initiated the save changes event.   Was it grid #1 or grid #4?  I can change the key information of the grid to embed this information as well, but wanted to check if there is another solution so I can determine which grid is trying to save changes.   Thanks much  

Parents
No Data
Reply
  • 17590
    Offline posted

    Hello Andrew,

    What I can suggest in order to determine which grid triggered saveChanges is passing the grid`s id as an argument to the action method in the controller. For example:

    @(Html.Infragistics().Grid(Model)
                                 .ID("grid1")
                                 .Width("100%")
                                 .AutoCommit(true)
                                 .AutoGenerateColumns(false)
                                 .PrimaryKey("ProductID")
                                 .Columns(col =>
                                 .Features(features =>
                                  {
                                      features.Updating();
                                  })
                                 .UpdateUrl(Url.Action("OrdersSaveData", new {gridID = "grid1"}))
                                    .DataSourceUrl(Url.Action("GetData"))
                                    .Render())
    

    Once we the OdersSaveData method is called the grid`s id will be passed to the controller so that you can get a reference to the id and determine which grid triggered the OrdersSaveData.

    public ActionResult OrdersSaveData(string gridID)
            {
                var gridIdentifier = gridID;
                GridModel gridModel = new GridModel();
                List<Transaction<Order>> transactions = gridModel.LoadTransactions<Order>(HttpContext.Request.Form["ig_transactions"]);
                .....

    Please let me know if you need any further assistance with this mater.

Children
No Data