BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
<div ng-app="employeeView"> <div ng-controller="GridCtrl"> OrderID : <input type="text" ng-model="logQuery.OrderID" class="textbox" /> <button ej-button e-field-size="large" e-field-showroundedcorner="true" ng-click="Search()">Search</button> <div ej-grid id="Grid" e-width="500px" e-datasource="data" e-allowsorting="true" e-allowPaging="true" e-toolbarsettings-showtoolbar="true" e-toolbarsettings-toolbaritems="tools"> <div e-columns> <div e-column e-field="OrderID" e-headertext="Order ID" e-isprimarykey="true" e-textalign="right"></div> <div e-column e-field="CustomerID" e-headertext="Customer ID" e-textalign="right"></div> <div e-column e-field="EmployeeID" e-headertext="Employee ID" e-textalign="right"></div> <div e-column e-field="Freight" e-headertext="Freight" e-textalign="right"></div> </div> </div> </div> </div>
<script> angular.module('custModule', []).factory("custService", ["$http", function ($http) {
return { get: function () { return $http.get("/api/Orders/?", { cache: true }); }, search: function (value) {
return $http.get("/api/Orders/?$inlinecount=allpages&$filter=(substringof(" + "'" + value + "'" + " ,tolower(OrderID))) or (substringof(" + "'" + value + "'" + ",tolower(CustomerID))) or (substringof(" + "'" + value + "'" + ",tolower(Freight))) or (substringof(" + "'" + value + "'" + ",tolower(ShipCountry)))") } }; }]);
angular.module('employeeView', ['ejangular','custModule']) .controller('GridCtrl', function ($scope, custService) {
$scope.tools = ["add", "edit", "delete", "update", "cancel"];
$scope.Search = function () { var grid = $("#Grid").ejGrid("instance"); var scope = angular.element($("#Grid")).scope(); custService.search(scope.logQuery.OrderID).then(onComplete); }
$scope.data = []; custService.get().then(
function (response) {
$scope.data = response.data.Items; } )
function onComplete(response) { $scope.data = response.data.Items; } }); </script> public PageResult<OrdersView> Get(ODataQueryOptions opts) { var results = db.OrdersViews.AsQueryable(); var count = results.Count(); if (opts.OrderBy != null) results = opts.OrderBy.ApplyTo(results); if (opts.Filter != null) { if (opts.Filter.RawValue.Contains("substring")) { string key = opts.Filter.RawValue.Split(new string[] { "'" }, StringSplitOptions.None)[1]; results = results.Where(fil => fil.CustomerID.Contains(key) || fil.EmployeeID.ToString().Contains(key) || fil.Freight.ToString().Contains(key) || fil.OrderID.ToString().Contains(key)); } else results = opts.Filter.ApplyTo(results, new ODataQuerySettings()).Cast<OrdersView>(); } if (opts.InlineCount != null) count = results.Count(); var data = results; //var count = emp.Count; //if (opts.Filter != null) // count = data.Cast<OrdersView>().ToList().Count;
return new PageResult<OrdersView>(results, null, count); |