Skip to content

Commit 76fb41b

Browse files
Zhuk, AlexanderZhuk, Alexander
Zhuk, Alexander
authored and
Zhuk, Alexander
committed
updating docs
1 parent abcc872 commit 76fb41b

File tree

3 files changed

+52
-20
lines changed

3 files changed

+52
-20
lines changed

README.md

+50-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,55 @@
11
#Angular Data Grid
22

3-
Light and flexible Data Grid for AngularJS applications.
3+
Light and flexible Data Grid for AngularJS, with built-in sorting, pagination and filtering options, unified API for client-side and server-side data fetching,
4+
seamless synchronization with browser address bar and total freedom in choosing mark-up and styling suitable for your application.
5+
6+
### Features
7+
8+
- Does not have any hard-coded template so you can choose any mark-up you need, from basic ```html <table>``` layout to any ```html <div>``` structure.
9+
- Easily switch between the most popular Bootstrap and Google Material theming, or apply your own CSS theme just by changing several CSS classes.
10+
- Built-in sync with browser address bar (URL), so you copy-n-paste sorting/filtering/pagination results URL and open it in other browser / send to anyone - even if pagination / filtering are done on a client-side.
11+
- Unlike most part of other Angular DataGrids, we intentionally use non-isolated scope of the directive, so it can be easily synchronized with any data changes inside your controller. !With great power comes great responsibility, so be careful to use non-isolated API correctly.
12+
13+
## Setup
14+
15+
1. Include scripts in you application: dataGrid.min.js and pagination.min.js (include the second one only if you need pagination), like:
16+
17+
```javascript
18+
<script src="components/angular-data-grid/pagination.min.js"></script>
19+
<script src="components/angular-data-grid/dataGrid.min.js"></script>
20+
```
21+
22+
2. Inject dataGrid dependency in your module:
23+
24+
```javascript
25+
angular.module('myApp', ['dataGrid', 'pagination'])
26+
```
27+
28+
3. Initialize grid with additional options in your controller, like:
29+
30+
```javascript
31+
$scope.gridOptions = {
32+
data: [], //required parameter - array with data
33+
//optional parameter - start sort options
34+
sort: {
35+
predicate: 'companyName',
36+
direction: 'asc'
37+
},
38+
//optional parameter - custom rules for filters (see explanation below)
39+
customFilters: {
40+
startFrom: function (items, value, predicate) {
41+
return items.filter(function (item) {
42+
return value && item[predicate] ? !item[predicate].toLowerCase().indexOf(value.toLowerCase()) : true;
43+
});
44+
}
45+
},
46+
//optional parameter - URL synchronization
47+
urlSync: true
48+
};
49+
```
50+
51+
## Sorting
52+
You can use the sortable directive to have a built in sort feature. You add the attribute sortable to your table headers. This will specify the property name you want to sort by. Also if you add class sortable to your element, sort arrows will be displayed for acs/decs sort directions.
453

554
You can use Data Grid module to easily display data in grids with built-in sorting, outer filters and url-synchronization. To use it, you must add grid-data directive to element and pass 2 required parameters ```grid-options``` and ```grid-actions```.
655

@@ -10,9 +59,6 @@ You can use Data Grid module to easily display data in grids with built-in sort
1059

1160
Inside the ```grid-data``` directive you can use grid-pagination directive. It's just wrapper of angular-ui pagination directive. You can pass any parameters from pagination directive. Also you can use grid-item-per-page directive and pass into it array of value (f.e. "10, 25, 50"). If you need get size of current displayed items you can use filtered variable.
1261

13-
##Sorting:
14-
You can use the sortable directive to have a built in sort feature. You add the attribute sortable to your table headers. This will specify the property name you want to sort by. Also if you add class sortable to your element, sort arrows will be displayed for acs/decs sort directions.
15-
1662
##Filters:
1763
Data Grid module has 4 types built in filters. To use it, you must add attribute filter-by to any element and pass property name, which you want filtering. Also you need add attribute filter-type with type of filter (text, select, dateFrom, dateTo). After that you need call filter() method in ng-change for text or select inputs and in ng-blur/ng-focus for datepickers. Filters synchronize with URL by ng-model value.
1864

demo/demoApp.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,9 @@ angular.module('myApp', ['dataGrid', 'pagination'])
1313

1414
$scope.gridOptions = {
1515
data: $scope.items,
16-
urlSync: true
16+
urlSync: false
1717
};
1818

19-
//$scope.items = [
20-
// {"firstName": "John", "lastName": "Doe"},
21-
// {"firstName": "Anna", "lastName": "Smith"},
22-
// {"firstName": "Peter", "lastName": "Jones"}
23-
//];
24-
25-
2619
}])
2720
.factory('myAppFactory', function ($http) {
2821
var root = 'http://jsonplaceholder.typicode.com';

src/js/demoApp.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,9 @@ angular.module('myApp', ['dataGrid', 'pagination'])
1313

1414
$scope.gridOptions = {
1515
data: $scope.items,
16-
urlSync: true
16+
urlSync: false
1717
};
1818

19-
//$scope.items = [
20-
// {"firstName": "John", "lastName": "Doe"},
21-
// {"firstName": "Anna", "lastName": "Smith"},
22-
// {"firstName": "Peter", "lastName": "Jones"}
23-
//];
24-
25-
2619
}])
2720
.factory('myAppFactory', function ($http) {
2821
var root = 'http://jsonplaceholder.typicode.com';

0 commit comments

Comments
 (0)