Code
<div ng-app="app" ng-controller="appCtrl">
<m-grid grid-options="gridOptions"></m-grid>
</div>
<script>
var app = angular.module('app', ['ui.bootstrap', 'm-grid']);
app.controller('appCtrl', function($scope) {
$scope.gridOptions = {
columns: [{
name: '#',
field: 'id'
}, {
name: 'Full name',
field: 'fullName'
}, {
name: 'Email',
field: 'email'
}],
sorting: true,
defaultSorting: 'id',
async: true,
asyncData: 'http://example.com/dataurl?term={term}&skip={skip}&take={take}&orderby={orderby}&flag={flag}',
asyncDataCount: 'http://example.com/datacounturl?term={term}&flag={flag}',
urlParams: {
flag: true
},
enableSearch: true
};
})
</script>
-
We can use a function who return a promise in
asyncData
and asyncDataCount
.
-
urlParams
is optional parameters for query
-
Internal query parameters is
term, orderby, skip, take, page, limit
-
We get orderby field. In ascending order we get fieldname and in desending order we get
-
prefix.
-
For sorting there two more options
sortby
and sorttype
. In sortby
, we will get only fieldname and in sorttype
we get asc|desc
.
-
Optional custom proeprty we can pass in urlParams.