-
Notifications
You must be signed in to change notification settings - Fork 16
/
ngtable.angular.txt
88 lines (79 loc) · 6.8 KB
/
ngtable.angular.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
NGTABLE
ALTERNATIVES ==> #See ng-grid
ngTable #Module. Adds pagination, sorting, filtering and grouping to <table>
#Angular JavaScript + CSS
#Must use Bootstrap CSS
#Version 0.4.3
ng-table[="OBJ_EXPR"] #Directive to put on <table> with:
# - class "table"
# - children <tr> (can use ng-repeat) with children:
# - <td> with data-title="'HEADER_NAME'"
#OBJ is new ngTableParams(OBJ2,OBJ3), where ngTableParams is a service.
#OBJ3:
# - getData($defer,params): loading of data. Must call $defer.resolve(OBJ_ARR).
# params is OBJ from new ngTableParams()
#$scope.$data receives OBJ_ARR. It should be used (e.g. with ng-repeat).
PAGINATION ==> # - OBJ:
# - page([NUM])
# - count([NUM])
# - total([NUM])
# - OBJ2:
# - page NUM (def: 1): page number
# - count NUM (def: 0): items per page
# - OBJ3:
# - total NUM (def: 0): total number of items. Often OBJ_ARR.length
# - counts NUM_ARR (def: [ 10, 25, 50, 100 ], [] to hide): items per page toggler
# - OBJ3.getData(): must call:
# $defer.resolve(OBJ_ARR.slice((OBJ.page() - 1) * OBJ.count(), OBJ.page() * OBJ.count()))
# ($defer is $q PROMISE)
# - pages: variable OBJ_ARR available:
# - number NUM
# - type "prev|next"
# - active BOOL
# - <table> attribute:
# - template-pagination="URL|TEMPLATE_ID", to replace HTML of pager (see online doc)
SORTING ==> # - OBJ:
# - sorting(): current sorting
# - sorting(OBJ): change it
# - isSortBy(OBJ)
# - orderBy(): current sorting, for use with Angular $filter orderBy
# - OBJ2:
# - sorting.VAR "asc|desc"
# - OBJ3:
# - defaultSort "desc|asc" (def: "desc"): def. when user clicks on column to sort
# - OBJ3.getData(): must call before $defer.resolve():
# OBJ2_ARR = OBJ.sorting() ? $filter("orderBy")(OBJ_ARR, OBJ.orderBy()) : OBJ_ARR;
# - <td> attributes: sortable="'VAR'", to let user sort by OBJ.VAR
FILTERING ==> # - OBJ:
# - filter(): current filtering
# - OBJ2:
# - filter.VAR VAL: filter only for entries whose column VAR == VAL
# - OBJ3:
# - filterDelay NUM (def: 750): before filter.VAR applies
# - OBJ3.getData():
# - must call before $defer.resolve():
# OBJ2_ARR = OBJ.filter() ? $filter("filter")(OBJ_ARR, OBJ.filter()) : OBJ_ARR;
# OBJ.total(OBJ2_ARR.length);
# - <table> attributes: show-filter="BOOL_EXPR" (def: false)
# - <td> attributes:
# - filter="OBJ_EXPR", where OBJ.VAR is either:
# - "text": text input
# - "select": dropdown menu
# - "VAR": only use OBJ2.filter.VAR / OBJ.filter().VAR
# - filter-data="STR_ARR": dropdown menu options
GROUPING ==> # - OBJ3:
# - groupBy VAR_STR|FUNC(OBJ)->STR: merge according to a column.
# Make $groups OBJ_ARR available, where ARR is grouped according to criteria.
# Must use OBJ.data instead of $data
# Should e.g.:
# - <tbody>: child of <table> and ng-repeat="OBJ4 in $groups", with two children:
# - <tr>: header, with class "ng-table-group". Should
# - <td colspan="{{$columns.length}}">
# - children can use:
# - group.$hideRows BOOL to collapse group (could use a <a> with arrow
# icon)
# - group.value STR: name of the group
# - <tr>s: normal content, but repeating OBJ4 as data and using
# ng-hide="group.$hideRows"