You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+50-25Lines changed: 50 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,17 @@
1
1
##Angular Data Grid
2
-
3
2
Light and flexible Data Grid for AngularJS apps, 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.
3
+
seamless synchronization with browser address bar and total freedom in mark-up and styling suitable for your application.
5
4
6
-
Demo Material Design: http://angular-data-grid.github.io/demo/
5
+
Demo Material Design: http://angular-data-grid.github.io/demo/material.html
- Does not have any hard-coded template so you can choose any mark-up you need, from basic ```<table>``` layout to any ```<div>``` structure.
12
10
- Easily switch between the most popular Bootstrap and Google Material theming, or apply your own CSS theme just by changing several CSS classes.
13
11
- 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.
14
12
- 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. !With great power comes great responsibility, so be careful to use non-isolated API correctly.
3. Initialize grid with additional options in your controller
39
+
3. Initialize grid with additional options in your controller. To do that, add ```grid-data``` directive to element and pass 2 required parameters ```grid-options``` and ```grid-actions```:
- For client-side pagination/filtering to fetch all data at once: just assign ```gridOptions.data``` to any JSON array object.
81
72
82
73
- 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:
@@ -94,21 +85,55 @@ And HTML:
94
85
```
95
86
96
87
### Sorting
97
-
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.
88
+
To enable sorting, just add attribute ```sortable``` to your table headers. This will specify the property name you want to sort by. Also you can add class ```sortable``` to display acs/decs arrows.
98
89
99
-
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```.
90
+
```HTML
91
+
<th sortable="code"class="sortable">
92
+
Order #
93
+
</th>
94
+
<th sortable="placed"class="sortable">
95
+
Date Placed
96
+
</th>
97
+
```
100
98
99
+
### Basic API
101
100
```grid-options``` : Name of object in your controller with start options for grid. You must create this object with at least 1 required parameter - data.
102
101
103
102
```grid-actions```: Name of object in your controller with functions for updating grid. You can can just pass string or create empty object in controller. Use this object for calling methods of directive: sort, filter, refresh.
104
103
105
-
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.
104
+
Inside the ```grid-data``` directive you can use grid-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 (e.g. "10, 25, 50"). If you need get size of current displayed items you can use filtered variable.
106
105
107
106
### Filters
108
-
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.
107
+
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. 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.
If you need use some custom filters (f.e. filter by first letter), you must add filter-by to specify property name, which you want filtering and add ng-model property. Then create in gridOptions.customFilters variable named as it ng-model value and contain filtering function. Filtering function accept items, value, predicate arguments and must return filtered array.
112
122
123
+
```javascript
124
+
125
+
$scope.gridOptions= {
126
+
data: [],
127
+
customFilters: {
128
+
startFrom:function (items, value, predicate) {
129
+
returnitems.filter(function (item) {
130
+
return value && item[predicate] ?!item[predicate].toLowerCase().indexOf(value.toLowerCase()) :true;
131
+
});
132
+
}
133
+
}
134
+
};
135
+
136
+
```
137
+
113
138
### Others
114
139
All filters has parameter disable-url. If you set it as true value - URL-synchronization for this filter will be disabled. If you need use 2 or more grids on page, you must add id to grids, and use grid-id attribute on filters to specify their grid.
0 commit comments