I am trying to use the Kendo Grid in an Angular controller. The DataSource posts to an MVC Controller. I need to send the data collected from the user in the form as well as the DataSourceRequst to the MVC Controller. My dataSource for the grid in the Angular controller looks like this:
dataSource: new kendo.data.DataSource({
type: "aspnetmvc-ajax",
transport: {
read: {
url: "/SSQV4/SSQV5/Search/SubmitCriteria",
data: { form: $scope.form }
}
},
schema: {
data: "Data",
total: "Total"
},
pageSize: 25,
serverPaging: true,
serverFiltering: true,
serverSorting: true
}),
The method in the MVC Controller looks like this:
public async Task<ActionResult> SubmitCriteria([DataSourceRequest]DataSourceRequest command, ContractorSearchViewModel form)
The problem is that is the values in $scope.form are set using ng-model on any inputs like <input type="text" ng-model="form.UnitID">, although it shows a value in $scope.form.UnitID in the Angular controller, when it reaches the MVC controller it is null. However, if instead of setting it from ng-model in an input, I set it manually in the Angular controller like $scope.form.UnitID = "123", then when the dataSource hits the MVC Controller, UnitID has value and is not null. I can I fix this? I need all of the information in the DataSourceRequest object as well as all of the information in the $scope.form object to get to my MVC Controller.
I also tried using a service like below:
transport: {
read: function (e) {
generalsearchService.submitSearch(e.data, form)
.then(function success(response) {
e.success(response.data);
});
}
},
When this hits the MVC controller, "form" is completely populated as desired, but e.data is missing the "filtering" and "sorting" which are null. It only contains page and pageSize. This has been a very frustrating process. Any assistance is greatly appreciated!