[GridFeatrues.cshtml]
<script type="text/javascript">
$(function () {
$("#Grid").ejGrid({
dataSource : ej.DataManager({
url : "/Grid/DataSource",
adaptor: "UrlAdaptor",
offline:true,
}),
allowPaging: true,
allowSorting: true,
sortSettings: { sortedColumns: [{ field: "EmployeeID", direction: "ascending" }] },
…
[GridController.cs]
public ActionResult DataSource(DataManager dm)
{
IEnumerable Data = OrderRepository.GetAllRecords().ToList();
Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations();
…
return Json(Data, JsonRequestBehavior.AllowGet);
} |
[Index.cshtml]
var filter, sortcolumn, page;
angular.module('custModule', []).factory("custService", ["$http", function ($http) {
return {
get: function () {
return $http.get("/api/Orders/?", { cache: true });
},
search: function (value) {
var a = filter;
filter.direction = filter.direction == "descending" ? "desc" : "asc";
return $http.get("/api/Orders/?$inlinecount=allpages&$orderby=" + filter.field + " " + filter.direction, { cache: true });
}
};
}]);
$scope.ActionBeginHandlers = function (args) {
if (args.requestType === "sorting") {
…
$scope.getList();
args.cancel = true;
}
}
$scope.getList = function () {
custService.search(filter).then(
function (response) {
$scope.data = response.data.Items;
$scope.dataCount = response.data.Count;
}
)
} |
$scope.ActionBeginHandlers = function (args) {
if (args.requestType === "sorting") {
…
$scope.getList();
args.cancel = true;
}
}
$scope.getList = function () {
custService.search(filter).then(
function (response) {
$scope.data = [{
"ShipPostalCode": "NT$39,984",
"OrderDate": "2016-08-17 15:56:50"
…
}, {
"ShipPostalCode": "NT$19,992",
…
}
];
$scope.dataCount = response.data.Count;
}
)
}
|