简体   繁体   中英

Passing Data from one Kendo Grid to another which resides inside a popup window

I'm using .net-core and Kendo-UI for a project.

I'm trying to pass checked(Each row has a checkbox) values from one Kendo Grid to another which resides in a popup window. This popup window is a bootstrap 4 popup that is called when the button is clicked. The problem is the grid in the popup window will not show the checked data.

How it works is the user checks off rows in the grid and then clicks a button which then fires a POST to the server. This post contains an array of the checked rows.

This array is then passed back through the controller to the other Kendo Grid inside the popup.

What I expect to happen is the data passed to the controller is passed back to this new grid. What is happening is the second grid remains empty. I checked the network tab in chrome tools and the controller is returning the data. Its just not finding its way to the grid.

Any ideas?

// Here is the controller function, ajax call and the kendo grid(popup).

// Controller function

public IActionResult SendInventoryGridData
([DataSourceRequest]DataSourceRequest request, string ViewBy, int BrandId, string[] Asins)
        {
            List <InventoryVM> Datalist= new List<InventoryVM>();

            foreach(string Asin in Asins)
            {
                Datalist.Add(new InventoryVM { Asin = Asin, Quantity = 1 });
            }
            var results = Datalist;
            return Json(results.ToDataSourceResult(request));
        }

// Ajax Post

        $.ajax({
            type: "POST", url: '@Url.Action("SendInventoryGridData", "InventoryManager")',
            success: function (data) {
                console.log(data);
            },
            data: { "ViewBy": viewBy, "BrandId": brandId, "Asins": Asins },
            accept: 'application/json'
        });

`````````````````````````````````````````````````````````````````````````




// Kendo Grid in popup window
`````````````````````````````````````````````````````````````````````
  @(Html.Kendo().Grid<Grit.WebUI.Models.Inventory.InventoryVM>()
 .Name("gReviewFeedbackCombo")
  .Columns(columns =>
    {
      columns.Bound(p => p.Asin).Title("Asin");
      columns.Bound(p => p.Quantity).Editable("productNameEditable");
      })
     .Scrollable(sc => sc.Endless(true))
     .HtmlAttributes(new { style = "height:400px;" })
     .DataSource(dataSource => dataSource
     .Ajax()
     .Model(model => model.Id(p => p.Asin))
     .Read(read => read.Action("SendInventoryGridData", "InventoryManager")))
     .Events(events => events.DataBound("dataBound")
         )
        )
``````````````````````````````````````````````````````````````````````````

After some thought I found an answer. I removed the ajax call and let the grid call the function itself. Worked like a charm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM