Hi There,
I am using Angular, KendoGrid, with MVC5 but The Sort/Group/Filter is always null in controller regardeless of what i have tried. I read many thread and i believe i am doing what i should do but the value are null. Please let me know what the issue is.
<script src="/Scripts/kendo/2016.3.914/jquery.min.js"></script>
<script src="/Scripts/kendo/2016.3.914/angular.min.js"></script>
<script src="/Scripts/kendo/2016.3.914/jszip.min.js"></script>
<script src="/Scripts/kendo/2016.3.914/kendo.all.min.js"></script>
<script src="/Scripts/kendo/2016.3.914/kendo.aspnetmvc.min.js"></script>
<div id="example" ng-app="MyApp">
<div ng-controller="supplierController" style="height:200px">
<kendo-grid options="supplierGridOptions">
</kendo-grid>
</div>
</div>
<script>
var myApp = angular.module("MyApp", ["kendo.directives"])
.controller("supplierController", function ($scope) {
height: 400,
$scope.supplierGridOptions = {
height:400,
columns: [
{field: "Name",title: "Name",width: "120px"},
{field: "OfficeAdresID",title: "OfficeAdresID", width: "120px"},
{field: "DeliveryAdresID",width: "DeliveryAdresID"},
{field: "BillingProfileID", width: "120px"},
{field: "Title"},
{ command: "destroy", title: "Delete", width: "110px" }
],
pageable: true,
sortable: {
mode: "multiple",
allowUnsort: true
},
filterable: true,
editable: true,
toolbar: ["create", "save", "cancel"],
dataSource: {
type: "aspnetmvc-ajax",
serverPaging: true,
serverFiltering: true,
serverSorting: true,
pageSize: 15,
schema: {
data: "Data",
total: "Total",
model: {
id: "ID",
fields: {
Name: { editable: true, type: "string", validation: { required: true } },
OfficeAdresID: { type: "number", editable: false },
DeliveryAdresID: { type: "number", editable: false },
BillingProfileID: { type: "number" },
Title: { type: "string", editable: false }
}
}
},
batch: true,
transport: {
read: {
url: "/Home/GetSupplier"
},
}
}
}
});
</script>
And the controller look like this:
public class HomeController : Controller
{
private MyContext db = new MyContext();
[HttpPost]
public JsonResult GetSupplier([DataSourceRequest] DataSourceRequest request)
{
DataSourceResult result = db.Suppliers.ToDataSourceResult(request);
return Json(result, JsonRequestBehavior.AllowGet);
}
}