` structure.
- Easily switch between the most popular Bootstrap and Google Material theming, or apply your own CSS theme just by changing several CSS classes.
- - Built-in sync with browser address bar (URL), so you can 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.
+ - Built-in sync with browser address bar (URL), so you can 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. [See details](#url-synchronization)
+ - Support of [Angular UI Router](https://github.com/angular-ui/ui-router) navigation.
+ - Optional support of fixed header table: [Bootstrap Demo](http://angular-data-grid.github.io/demo/fixed-header/bootstrap-grid.html) [Material Design Demo](http://angular-data-grid.github.io/demo/fixed-header/angular-md-grid.html)
+ - Optional support of CSV data exports: [Demo](http://angular-data-grid.github.io/demo/bootstrap/)
- Unlike most part of other Angular DataGrids, we intentionally use non-isolated scope of the directive to maximize flexibility, so it can be easily synchronized with any data changes inside your controller.
- NOTE! With great power comes great responsibility, so use non-isolated API carefully.
+ NOTE! With great power comes great responsibility, so use non-isolated API wisely.
### Installation
Using Bower: `bower install angular-data-grid`
+Using NPM: `npm install angular-data-grid`
+
Direct download: get ZIP archive [from here](https://github.com/angular-data-grid/angular-data-grid.github.io/archive/master.zip)
Then use files from *dist* folder (see below).
### Setup
-1. Include scripts in you application: `dataGrid.min.js` and `pagination.min.js` (include the second one only if you need pagination).
+1. Include scripts in you application: `angular.min.js`, `dataGrid.min.js` and `pagination.min.js` (include the second one only if you need pagination).
```javascript
+
```
@@ -80,18 +89,12 @@ angular.module('myApp', ['dataGrid', 'pagination'])
sort: {
predicate: 'companyName',
direction: 'asc'
- },
- //optional parameter - custom rules for filters (see explanation below)
- customFilters: {
- startFrom: function (items, value, predicate) {
- return items.filter(function (item) {
- return value && item[predicate] ? !item[predicate].toLowerCase().indexOf(value.toLowerCase()) : true;
- });
- }
}
};
```
+NOTE: `grid-item` wrapper directive used in the example above, to make code more concise, but you can always use regular `ng-repeat` instead, like: `ng-repeat="item in filtered | startFrom:(paginationOptions.currentPage-1)*paginationOptions.itemsPerPage | limitTo:paginationOptions.itemsPerPage track by $index"`
+
### Basic API
1. `grid-options`: object in your controller with start options for grid. You must create this object with at least 1 required parameter - data.
@@ -109,7 +112,10 @@ Use this object for calling methods of directive: `sort()`, `filter()`, `refresh
};
```
- - For server side pagination/filtering to fetch data by page: assign ```getData``` method to some function with URL params as 1st parameter and data itself as 2d parameter:
+ - For server side pagination/filtering to fetch data by page:
+ 1. add attribute 'server-pagination'=true on element on which you applied directive 'grid-data'
+ 2. assign ```getData``` method to some function with URL params as 1st parameter and data itself as 2d parameter:
+
```javascript
$scope.gridOptions = {
@@ -149,7 +155,7 @@ $scope.gridOptions = {
### Pagination
-You can optionally use `pagination` directive to display paging with previous/next and first/last controls.
+You can optionally use `grid-pagination` directive to display paging with previous/next and first/last controls.
Directive is built on a base of excellent [Angular UI](https://angular-ui.github.io/bootstrap/) component and shares extensive API:
```HTML
@@ -162,7 +168,7 @@ Directive is built on a base of excellent [Angular UI](https://angular-ui.github
```
-Settings can be provided as attributes in the
or globally configured through the paginationConfig.
+Settings can be provided as attributes in the or globally configured through the `paginationConfig`.
```ng-change``` : ng-change can be used together with ng-model to call a function whenever the page changes.
@@ -196,8 +202,8 @@ Settings can be provided as attributes in the or globally configure
### Filters
Data Grid supports 4 built-in types of filters: `text`, `select`, `dateFrom` and `dateTo`.
-To use it, 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.
+To use it, add attribute `filter-by` to any element and pass property name, which you want to be filtered.
+Also you need add attribute `filter-type` with type of filter.
After that you need call `filter()` method in `ng-change` for text or select inputs and in `ng-blur/ng-focus` for datepickers.
Filters are synchronized with URL by `ng-model` value.
@@ -213,7 +219,7 @@ Filters are synchronized with URL by `ng-model` value.
```
### Custom Filters
-If you need use some custom filters (f.e. filter by first letter), add `filter-by` to specify property name, which you want filtering and add `ng-model` property.
+If you need to use some custom filters (e.g. filter by first letter), add `filter-by` to specify property name, which you want filtering and add `ng-model` property.
Then create in `gridOptions.customFilters` variable named as `ng-model` with filtering function. Filtering function accepts items, value, predicate arguments and returns filtered array.
```javascript
@@ -231,7 +237,18 @@ Then create in `gridOptions.customFilters` variable named as `ng-model` with fil
```
-### Others
-All filters have optional parameter `disable-url`. If you set it to **true**, URL-synchronization for this filter will be disabled.
+### URL Synchronization
+You can disable/enable URL synchronization for the whole grid or on a level of particular filter.
+
+Global parameter `gridOptions.urlSync` (boolean, default is 'false') works for the whole grid.
+
+Each filter has optional parameter `disable-url` (boolean, default is 'false'). If you set it to **true**, URL-synchronization for this particular filter will be disabled.
+
+
+### Multiple grids on page
+If you need to use 2 or more grids on page, please add `id` to grids, and then use `grid-id` attribute on filters to specify their corresponding grid. [Example](http://angular-data-grid.github.io/demo/bootstrap/multiple.html)
-If you need to use 2 or more grids on page, please add id to grids, and then use ```grid-id``` attribute on filters to specify their corresponding grid.
+### Next / Future
+ - Migrate to Heroku
+ - Cover with unit / e2e tests
+ - Port to Angular2?
diff --git a/demo/100k/index.html b/demo/100k/index.html
index d16ea35..4ce1f28 100644
--- a/demo/100k/index.html
+++ b/demo/100k/index.html
@@ -207,14 +207,14 @@ Angular Data Grid 100k Example