Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9bc93f

Browse files
committed
Update litmus example
1 parent 6172abf commit e9bc93f

File tree

1 file changed

+86
-5
lines changed

1 file changed

+86
-5
lines changed

litmus/bugs/GridDefaultSortFieldClearableSortIssue.js

Lines changed: 86 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,57 @@
11
import { KeySelection } from "cx/ui";
2-
import { Grid, PureContainer } from "cx/widgets";
2+
import { Grid, PureContainer, Repeater } from "cx/widgets";
33
import { casual } from "../casual.js";
44

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+
];
533
export default () => (
634
<cx>
735
<PureContainer
836
controller={{
937
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) => ({
1139
id: i + 1,
1240
fullName: casual.full_name,
1341
continent: casual.continent,
1442
browser: casual.browser,
1543
os: casual.operating_system,
1644
visits: casual.integer(1, 100)
1745
})));
46+
this.store.init('$page.groups', groupsData);
1847
},
1948
}}
2049
>
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>
2353
<Grid records-bind='$page.records'
24-
style={{ height: '600px', width: '1000px', marginTop: '10px' }}
54+
style={{ height: '200px', width: '1000px', marginTop: '10px' }}
2555
mod="responsive"
2656
scrollable
2757
clearableSort
@@ -36,6 +66,57 @@ export default () => (
3666
selection={{ type: KeySelection, bind: '$page.selection', multiple: true }}
3767
/>
3868
</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>
39120
</PureContainer>
40121
</cx>
41122
);

0 commit comments

Comments
 (0)