I am wanting to pass only the rows where the checkbox is checked to my controller but I can not seem to figure this out. I don't want to use selected but checked boxes.
Scenario: user is presented with a list of products, some of which are pre-checked. they will then select more products by checking the checkboxes. I want to send all those rows to the controller, and also have it work with paging. Is there a way to change the following from using "selected" to use the checked?
// gather the selected rows and send them to the controller $(function () { $('#btnGenerate').click(function () { var grid = $('#products').data('kendoGrid'); var selectedElements = grid.select(); for (var j = 0; j < selectedElements.length; j++) { var item = grid.dataItem(selectedElements[j]); items['products[' + j + '].ItemDescription'] = item.ItemDescription; items['products[' + j + '].Quantity'] = item.Quantity; } $.ajax({ type: "POST", data: items, url: '@Url.Action("ProductsCart","Trial")', success: function () { window.location.href = "@Url.Action("ProductsCart", "Trial")"; }, error: function () { alert("No products were selected."); } }); }); });
// POST: Add Trial Products to cart[HttpPost]public ActionResult ProductsCart(TrialProductViewModel[] products){ // do something with products return Json(products);}