Skip to content

Commit ed82721

Browse files
authored
Merge pull request #551 from wenzhixin/feature/group-by
Enhance group-by-v2 example with full configuration
2 parents 5958310 + 1639976 commit ed82721

File tree

1 file changed

+34
-21
lines changed

1 file changed

+34
-21
lines changed

extensions/group-by-v2.html

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,43 @@
1414
</script>
1515

1616
<template>
17-
<table
18-
id="table"
19-
data-group-by="true"
20-
data-group-by-field="shape"
21-
data-url="json/data6.json"
22-
>
23-
<thead>
24-
<tr>
25-
<th data-field="shape">
26-
Shape
27-
</th>
28-
<th data-field="color">
29-
Color
30-
</th>
31-
<th data-field="area">
32-
Area
33-
</th>
34-
</tr>
35-
</thead>
36-
</table>
17+
<table id="table"></table>
3718
</template>
3819

3920
<script>
4021
function mounted () {
41-
$('#table').bootstrapTable()
22+
$('#table').bootstrapTable({
23+
url: 'json/data6.json',
24+
groupBy: true,
25+
groupByField: 'shape',
26+
groupByFormatter: value => {
27+
const strong = document.createElement('strong')
28+
29+
strong.className = 'text-primary'
30+
strong.textContent = `GROUP: ${value}`
31+
return strong.outerHTML
32+
},
33+
columns: [
34+
{
35+
field: 'state',
36+
checkbox: true
37+
},
38+
{
39+
field: 'shape',
40+
title: 'Shape',
41+
sortable: true
42+
},
43+
{
44+
field: 'color',
45+
title: 'Color',
46+
sortable: true
47+
},
48+
{
49+
field: 'area',
50+
title: 'Area',
51+
sortable: true
52+
}
53+
]
54+
})
4255
}
4356
</script>

0 commit comments

Comments
 (0)