1
1
import { KeySelection } from "cx/ui" ;
2
- import { Grid , PureContainer } from "cx/widgets" ;
2
+ import { Grid , PureContainer , Repeater } from "cx/widgets" ;
3
3
import { casual } from "../casual.js" ;
4
4
5
+ const groupsData = [
6
+ {
7
+ name : "Group Alpha" ,
8
+ items : [
9
+ { id : 1 , name : "Item Alpha-1" , value : 15 } ,
10
+ { id : 3 , name : "Item Alpha-3" , value : 35 } ,
11
+ { id : 2 , name : "Item Alpha-2" , value : 25 }
12
+ ]
13
+ } ,
14
+ {
15
+ name : "Group Beta" ,
16
+ items : [
17
+ { id : 4 , name : "Item Beta-1" , value : 45 } ,
18
+ { id : 5 , name : "Item Beta-2" , value : 55 }
19
+ ]
20
+ } ,
21
+ {
22
+ name : "Group Gamma" ,
23
+ items : [
24
+ { id : 6 , name : "Item Gamma-1" , value : 65 } ,
25
+ { id : 7 , name : "Item Gamma-2" , value : 75 } ,
26
+ { id : 9 , name : "Item Gamma-4" , value : 95 } ,
27
+ { id : 10 , name : "Item Gamma-5" , value : 95 } ,
28
+ { id : 8 , name : "Item Gamma-3" , value : 85 } ,
29
+ { id : 11 , name : "Item Gamma-6" , value : 95 }
30
+ ]
31
+ }
32
+ ] ;
5
33
export default ( ) => (
6
34
< cx >
7
35
< PureContainer
8
36
controller = { {
9
37
init ( ) {
10
- this . store . init ( '$page.records' , Array . from ( { length : 20 } ) . map ( ( v , i ) => ( {
38
+ this . store . init ( '$page.records' , Array . from ( { length : 6 } ) . map ( ( v , i ) => ( {
11
39
id : i + 1 ,
12
40
fullName : casual . full_name ,
13
41
continent : casual . continent ,
14
42
browser : casual . browser ,
15
43
os : casual . operating_system ,
16
44
visits : casual . integer ( 1 , 100 )
17
45
} ) ) ) ;
46
+ this . store . init ( '$page.groups' , groupsData ) ;
18
47
} ,
19
48
} }
20
49
>
21
- < div style = "margin:40px" >
22
- < i > When default sort field is set, clearable sort is not behaving as expected and only offers two state: ASC and DESC. This is related to the issue #1246.</ i >
50
+ < i > When default sort field is set, clearable sort is not behaving as expected and only offers two state: ASC and DESC. This is related to the issue #1246.</ i >
51
+ < div style = "margin:5x; height:240px;" >
52
+ < h3 > Clearable sort and default sort field.</ h3 >
23
53
< Grid records-bind = '$page.records'
24
- style = { { height : '600px ' , width : '1000px' , marginTop : '10px' } }
54
+ style = { { height : '200px ' , width : '1000px' , marginTop : '10px' } }
25
55
mod = "responsive"
26
56
scrollable
27
57
clearableSort
@@ -36,6 +66,57 @@ export default () => (
36
66
selection = { { type : KeySelection , bind : '$page.selection' , multiple : true } }
37
67
/>
38
68
</ div >
69
+
70
+ < div style = "margin:5px; height:240px;" >
71
+ < h3 > No default sort field.</ h3 >
72
+ < Grid records-bind = '$page.records'
73
+ style = { { height : '200px' , width : '1000px' , marginTop : '10px' } }
74
+ mod = "responsive"
75
+ scrollable
76
+ clearableSort
77
+ columns = { [
78
+ { header : 'Name' , field : 'fullName' , sortable : true , resizable : true } ,
79
+ { header : 'Continent' , field : 'continent' , sortable : true , resizable : true } ,
80
+ { header : 'Browser' , field : 'browser' , sortable : true , resizable : true } ,
81
+ { header : 'OS' , field : 'os' , sortable : true , resizable : true } ,
82
+ { header : 'Visits' , field : 'visits' , sortable : true , align : 'right' , resizable : true , primarySortDirection : 'DESC' }
83
+ ] }
84
+ selection = { { type : KeySelection , bind : '$page.selection' , multiple : true } }
85
+ />
86
+ </ div >
87
+
88
+ < div style = "margin:5px; height:240px;" >
89
+ < h3 > No clerable sort.</ h3 >
90
+ < Grid records-bind = '$page.records'
91
+ style = { { height : '200px' , width : '1000px' , marginTop : '10px' } }
92
+ mod = "responsive"
93
+ scrollable
94
+ defaultSortField = 'fullName'
95
+ columns = { [
96
+ { header : 'Name' , field : 'fullName' , sortable : true , resizable : true } ,
97
+ { header : 'Continent' , field : 'continent' , sortable : true , resizable : true } ,
98
+ { header : 'Browser' , field : 'browser' , sortable : true , resizable : true } ,
99
+ { header : 'OS' , field : 'os' , sortable : true , resizable : true } ,
100
+ { header : 'Visits' , field : 'visits' , sortable : true , align : 'right' , resizable : true , primarySortDirection : 'DESC' }
101
+ ] }
102
+ selection = { { type : KeySelection , bind : '$page.selection' , multiple : true } }
103
+ />
104
+ </ div >
105
+ < h2 > Within repeater</ h2 >
106
+ < Repeater style = "height:100px"
107
+ records-bind = "$page.groups"
108
+ recordAlias = "$group" >
109
+ < h3 text-bind = "$group.name" />
110
+ < Grid style = "width:200px;height:100px"
111
+ records-bind = "$group.items"
112
+ clearableSort
113
+ defaultSortField = "name"
114
+ columns = { [
115
+ { header : "Name" , field : "name" , sortable : true } ,
116
+ { header : "Value" , field : "value" , sortable : true }
117
+ ] }
118
+ />
119
+ </ Repeater >
39
120
</ PureContainer >
40
121
</ cx >
41
122
) ;
0 commit comments