/
CustomizeCell.dart
55 lines (50 loc) · 2.22 KB
/
CustomizeCell.dart
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
import 'package:flutter/material.dart';
import 'package:flutter_flexmonster/flutter_flexmonster.dart';
import 'package:webview_flutter/webview_flutter.dart';
class CustomizeCell extends StatefulWidget {
const CustomizeCell({super.key});
@override
State<CustomizeCell> createState() => _CustomizeCellState();
}
class _CustomizeCellState extends State<CustomizeCell> {
Flexmonster pivot = Flexmonster(
width: "100%",
height: "500",
toolbar: true,
report: "https://cdn.flexmonster.com/github/demo-report.json");
@override
void initState() {
super.initState();
pivot.on("reportcomplete", () async {
WebViewController controller = await pivot.controller.future;
controller.runJavascript('''
flexmonster.customizeCell(customizeCellFunction);
function customizeCellFunction(cell, data) {
if (data.type == "header" && data.hierarchy && data.hierarchy.caption == "Country" && data.member && data.member.properties) {
const name = data.member.properties.CurrencyID;
cell.addClass('fm-custom-cell');
let flag;
let style = `<style type="text/css">
.fm-custom-cell .flag-icon {
width: 21px !important;
height: 16px !important;
margin-left: 0 !important;
margin-right: 2px !important;
}
</style>`;
if (data.expanded) {
flag = `\${style}<i class="fm-icon fm-expanded-icon" title="Click to collapse"></i><img class="flag-icon" src="https://cdn.flexmonster.com/flags/\${name.toLowerCase()}.svg">`;
} else {
flag = `\${style}<i class="fm-icon fm-collapsed-icon" title="Click to expand"></i>
<img class="flag-icon" src="https://cdn.flexmonster.com/flags/\${name.toLowerCase()}.svg">`;
}
cell.text = `\${style}<div style="display:flex; align-items:center; font-size:12px; position:relative;">\${flag}<span style="margin-left: 2px; line-height: 16px;">\${data.member.caption}</span></div>`;
}
}''');
});
}
@override
Widget build(BuildContext context) {
return Column(children: [SizedBox(height: 500, child: pivot)]);
}
}