x4js 1.4.52 → 1.4.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/lib/{action.js → cjs/action.js} +0 -0
  2. package/lib/{application.js → cjs/application.js} +13 -19
  3. package/lib/{autocomplete.js → cjs/autocomplete.js} +0 -4
  4. package/lib/cjs/base_component.js +124 -0
  5. package/lib/{button.js → cjs/button.js} +4 -4
  6. package/lib/{calendar.js → cjs/calendar.js} +22 -22
  7. package/lib/{canvas.js → cjs/canvas.js} +7 -8
  8. package/lib/{cardview.js → cjs/cardview.js} +3 -5
  9. package/lib/{checkbox.js → cjs/checkbox.js} +6 -5
  10. package/lib/cjs/color.js +591 -0
  11. package/lib/{colorpicker.js → cjs/colorpicker.js} +1 -14
  12. package/lib/{combobox.js → cjs/combobox.js} +2 -6
  13. package/lib/{component.js → cjs/component.js} +16 -25
  14. package/lib/{datastore.js → cjs/datastore.js} +18 -32
  15. package/lib/{dialog.js → cjs/dialog.js} +4 -21
  16. package/lib/{dom_events.js → cjs/dom_events.js} +0 -0
  17. package/lib/{drag_manager.js → cjs/drag_manager.js} +0 -5
  18. package/lib/{drawtext.js → cjs/drawtext.js} +5 -4
  19. package/lib/{fileupload.js → cjs/fileupload.js} +0 -3
  20. package/lib/{form.js → cjs/form.js} +2 -6
  21. package/lib/{formatters.js → cjs/formatters.js} +0 -0
  22. package/lib/{gridview.js → cjs/gridview.js} +20 -33
  23. package/lib/{i18n.js → cjs/i18n.js} +0 -0
  24. package/lib/{icon.js → cjs/icon.js} +17 -11
  25. package/lib/{image.js → cjs/image.js} +4 -5
  26. package/lib/{index.js → cjs/index.js} +0 -0
  27. package/lib/cjs/input.js +174 -0
  28. package/lib/{label.js → cjs/label.js} +2 -1
  29. package/lib/{layout.js → cjs/layout.js} +9 -8
  30. package/lib/{link.js → cjs/link.js} +3 -2
  31. package/lib/cjs/listview.js +544 -0
  32. package/{src/md5.ts → lib/cjs/md5.js} +403 -438
  33. package/lib/{menu.js → cjs/menu.js} +4 -11
  34. package/lib/{messagebox.js → cjs/messagebox.js} +4 -4
  35. package/lib/{panel.js → cjs/panel.js} +3 -4
  36. package/lib/{popup.js → cjs/popup.js} +4 -5
  37. package/lib/{property_editor.js → cjs/property_editor.js} +2 -5
  38. package/lib/{radiobtn.js → cjs/radiobtn.js} +6 -6
  39. package/lib/{rating.js → cjs/rating.js} +7 -6
  40. package/lib/cjs/request.js +246 -0
  41. package/lib/{router.js → cjs/router.js} +0 -1
  42. package/lib/cjs/settings.js +69 -0
  43. package/lib/{sidebarview.js → cjs/sidebarview.js} +2 -3
  44. package/lib/{spreadsheet.js → cjs/spreadsheet.js} +10 -27
  45. package/lib/{styles.js → cjs/styles.js} +5 -6
  46. package/lib/{svgcomponent.js → cjs/svgcomponent.js} +3 -11
  47. package/lib/{tabbar.js → cjs/tabbar.js} +5 -5
  48. package/lib/{tabview.js → cjs/tabview.js} +0 -2
  49. package/lib/{textarea.js → cjs/textarea.js} +4 -3
  50. package/lib/{textedit.js → cjs/textedit.js} +7 -8
  51. package/lib/{toaster.js → cjs/toaster.js} +0 -2
  52. package/lib/{tools.js → cjs/tools.js} +7 -16
  53. package/lib/{tooltips.js → cjs/tooltips.js} +0 -1
  54. package/lib/{treeview.js → cjs/treeview.js} +23 -19
  55. package/lib/{action.d.ts → cjs/types/action.d.ts} +0 -0
  56. package/lib/{application.d.ts → cjs/types/application.d.ts} +0 -0
  57. package/lib/{autocomplete.d.ts → cjs/types/autocomplete.d.ts} +0 -0
  58. package/lib/{base_component.d.ts → cjs/types/base_component.d.ts} +0 -0
  59. package/lib/{button.d.ts → cjs/types/button.d.ts} +0 -0
  60. package/lib/{calendar.d.ts → cjs/types/calendar.d.ts} +0 -0
  61. package/lib/{canvas.d.ts → cjs/types/canvas.d.ts} +0 -0
  62. package/lib/{cardview.d.ts → cjs/types/cardview.d.ts} +0 -0
  63. package/lib/{checkbox.d.ts → cjs/types/checkbox.d.ts} +0 -0
  64. package/lib/{color.d.ts → cjs/types/color.d.ts} +0 -0
  65. package/lib/{colorpicker.d.ts → cjs/types/colorpicker.d.ts} +0 -0
  66. package/lib/{combobox.d.ts → cjs/types/combobox.d.ts} +0 -0
  67. package/lib/{component.d.ts → cjs/types/component.d.ts} +0 -0
  68. package/lib/{datastore.d.ts → cjs/types/datastore.d.ts} +0 -0
  69. package/lib/{dialog.d.ts → cjs/types/dialog.d.ts} +0 -0
  70. package/lib/{dom_events.d.ts → cjs/types/dom_events.d.ts} +0 -0
  71. package/lib/{drag_manager.d.ts → cjs/types/drag_manager.d.ts} +0 -0
  72. package/lib/{drawtext.d.ts → cjs/types/drawtext.d.ts} +0 -0
  73. package/lib/{fileupload.d.ts → cjs/types/fileupload.d.ts} +0 -0
  74. package/lib/{form.d.ts → cjs/types/form.d.ts} +0 -0
  75. package/lib/{formatters.d.ts → cjs/types/formatters.d.ts} +0 -0
  76. package/lib/{gridview.d.ts → cjs/types/gridview.d.ts} +0 -0
  77. package/lib/{i18n.d.ts → cjs/types/i18n.d.ts} +0 -0
  78. package/lib/{icon.d.ts → cjs/types/icon.d.ts} +0 -0
  79. package/lib/{image.d.ts → cjs/types/image.d.ts} +0 -0
  80. package/lib/{index.d.ts → cjs/types/index.d.ts} +0 -0
  81. package/lib/{input.d.ts → cjs/types/input.d.ts} +0 -0
  82. package/lib/{label.d.ts → cjs/types/label.d.ts} +0 -0
  83. package/lib/{layout.d.ts → cjs/types/layout.d.ts} +0 -0
  84. package/lib/{link.d.ts → cjs/types/link.d.ts} +0 -0
  85. package/lib/{listview.d.ts → cjs/types/listview.d.ts} +0 -0
  86. package/lib/{md5.d.ts → cjs/types/md5.d.ts} +0 -0
  87. package/lib/{menu.d.ts → cjs/types/menu.d.ts} +0 -0
  88. package/lib/{messagebox.d.ts → cjs/types/messagebox.d.ts} +0 -0
  89. package/lib/{panel.d.ts → cjs/types/panel.d.ts} +0 -0
  90. package/lib/{popup.d.ts → cjs/types/popup.d.ts} +0 -0
  91. package/lib/{property_editor.d.ts → cjs/types/property_editor.d.ts} +0 -0
  92. package/lib/{radiobtn.d.ts → cjs/types/radiobtn.d.ts} +0 -0
  93. package/lib/{rating.d.ts → cjs/types/rating.d.ts} +0 -0
  94. package/lib/{request.d.ts → cjs/types/request.d.ts} +0 -0
  95. package/lib/{router.d.ts → cjs/types/router.d.ts} +0 -0
  96. package/lib/{settings.d.ts → cjs/types/settings.d.ts} +0 -0
  97. package/lib/{sidebarview.d.ts → cjs/types/sidebarview.d.ts} +0 -0
  98. package/lib/{spreadsheet.d.ts → cjs/types/spreadsheet.d.ts} +0 -0
  99. package/lib/{styles.d.ts → cjs/types/styles.d.ts} +0 -0
  100. package/lib/{svgcomponent.d.ts → cjs/types/svgcomponent.d.ts} +0 -0
  101. package/lib/{tabbar.d.ts → cjs/types/tabbar.d.ts} +0 -0
  102. package/lib/{tabview.d.ts → cjs/types/tabview.d.ts} +0 -0
  103. package/lib/{textarea.d.ts → cjs/types/textarea.d.ts} +0 -0
  104. package/lib/{textedit.d.ts → cjs/types/textedit.d.ts} +0 -0
  105. package/lib/{toaster.d.ts → cjs/types/toaster.d.ts} +0 -0
  106. package/lib/{tools.d.ts → cjs/types/tools.d.ts} +0 -0
  107. package/lib/{tooltips.d.ts → cjs/types/tooltips.d.ts} +0 -0
  108. package/lib/{treeview.d.ts → cjs/types/treeview.d.ts} +0 -0
  109. package/lib/{version.d.ts → cjs/types/version.d.ts} +0 -0
  110. package/lib/{x4dom.d.ts → cjs/types/x4dom.d.ts} +0 -0
  111. package/lib/{x4events.d.ts → cjs/types/x4events.d.ts} +0 -0
  112. package/lib/{x4react.d.ts → cjs/types/x4react.d.ts} +0 -0
  113. package/lib/{version.js → cjs/version.js} +0 -0
  114. package/lib/{x4dom.js → cjs/x4dom.js} +0 -0
  115. package/lib/{x4events.js → cjs/x4events.js} +6 -11
  116. package/lib/{x4react.js → cjs/x4react.js} +1 -4
  117. package/lib/esm/action.js +53 -0
  118. package/lib/esm/application.js +184 -0
  119. package/lib/esm/autocomplete.js +155 -0
  120. package/lib/{base_component.js → esm/base_component.js} +3 -7
  121. package/lib/esm/button.js +257 -0
  122. package/lib/esm/calendar.js +244 -0
  123. package/lib/esm/canvas.js +358 -0
  124. package/lib/esm/cardview.js +159 -0
  125. package/lib/esm/checkbox.js +133 -0
  126. package/lib/{color.js → esm/color.js} +3 -7
  127. package/lib/esm/colorpicker.js +1475 -0
  128. package/lib/esm/combobox.js +259 -0
  129. package/lib/esm/component.js +1711 -0
  130. package/lib/esm/datastore.js +990 -0
  131. package/lib/esm/dialog.js +490 -0
  132. package/lib/{base64.d.ts → esm/dom_events.js} +2 -8
  133. package/lib/esm/drag_manager.js +147 -0
  134. package/lib/esm/drawtext.js +271 -0
  135. package/lib/esm/fileupload.js +163 -0
  136. package/lib/esm/form.js +297 -0
  137. package/lib/esm/formatters.js +81 -0
  138. package/lib/esm/gridview.js +889 -0
  139. package/lib/esm/i18n.js +257 -0
  140. package/lib/esm/icon.js +256 -0
  141. package/lib/esm/image.js +154 -0
  142. package/lib/esm/index.mjs +86 -0
  143. package/lib/{input.js → esm/input.js} +2 -6
  144. package/lib/esm/label.js +90 -0
  145. package/lib/esm/layout.js +310 -0
  146. package/lib/esm/link.js +59 -0
  147. package/lib/{listview.js → esm/listview.js} +30 -36
  148. package/lib/{md5.js → esm/md5.js} +1 -5
  149. package/lib/esm/menu.js +300 -0
  150. package/lib/esm/messagebox.js +145 -0
  151. package/lib/esm/panel.js +65 -0
  152. package/lib/esm/popup.js +379 -0
  153. package/lib/esm/property_editor.js +251 -0
  154. package/lib/esm/radiobtn.js +136 -0
  155. package/lib/esm/rating.js +97 -0
  156. package/lib/{request.js → esm/request.js} +9 -16
  157. package/lib/esm/router.js +136 -0
  158. package/lib/{settings.js → esm/settings.js} +1 -5
  159. package/lib/esm/sidebarview.js +79 -0
  160. package/lib/esm/spreadsheet.js +1091 -0
  161. package/lib/esm/styles.js +270 -0
  162. package/lib/esm/svgcomponent.js +422 -0
  163. package/lib/esm/tabbar.js +107 -0
  164. package/lib/esm/tabview.js +83 -0
  165. package/lib/esm/textarea.js +123 -0
  166. package/lib/esm/textedit.js +412 -0
  167. package/lib/esm/toaster.js +62 -0
  168. package/lib/esm/tools.js +1155 -0
  169. package/lib/esm/tooltips.js +153 -0
  170. package/lib/esm/treeview.js +495 -0
  171. package/lib/esm/types/action.d.ts +57 -0
  172. package/lib/esm/types/application.d.ts +104 -0
  173. package/lib/esm/types/autocomplete.d.ts +58 -0
  174. package/lib/esm/types/base_component.d.ts +88 -0
  175. package/lib/esm/types/button.d.ts +151 -0
  176. package/lib/esm/types/calendar.d.ts +81 -0
  177. package/lib/esm/types/canvas.d.ts +92 -0
  178. package/lib/esm/types/cardview.d.ts +87 -0
  179. package/lib/esm/types/checkbox.d.ts +77 -0
  180. package/lib/esm/types/color.d.ts +148 -0
  181. package/lib/esm/types/colorpicker.d.ts +107 -0
  182. package/lib/esm/types/combobox.d.ts +101 -0
  183. package/lib/esm/types/component.d.ts +601 -0
  184. package/lib/esm/types/datastore.d.ts +396 -0
  185. package/lib/esm/types/dialog.d.ts +175 -0
  186. package/lib/esm/types/dom_events.d.ts +302 -0
  187. package/lib/esm/types/drag_manager.d.ts +54 -0
  188. package/lib/esm/types/drawtext.d.ts +48 -0
  189. package/lib/esm/types/fileupload.d.ts +64 -0
  190. package/lib/esm/types/form.d.ts +126 -0
  191. package/lib/esm/types/formatters.d.ts +35 -0
  192. package/lib/esm/types/gridview.d.ts +175 -0
  193. package/lib/esm/types/i18n.d.ts +73 -0
  194. package/lib/esm/types/icon.d.ts +64 -0
  195. package/lib/esm/types/image.d.ts +55 -0
  196. package/lib/esm/types/index.d.ts +83 -0
  197. package/lib/esm/types/input.d.ts +91 -0
  198. package/lib/esm/types/label.d.ts +58 -0
  199. package/lib/esm/types/layout.d.ts +87 -0
  200. package/lib/esm/types/link.d.ts +50 -0
  201. package/lib/esm/types/listview.d.ts +178 -0
  202. package/lib/esm/types/md5.d.ts +61 -0
  203. package/lib/esm/types/menu.d.ts +130 -0
  204. package/lib/esm/types/messagebox.d.ts +68 -0
  205. package/lib/esm/types/panel.d.ts +47 -0
  206. package/lib/esm/types/popup.d.ts +75 -0
  207. package/lib/esm/types/property_editor.d.ts +71 -0
  208. package/lib/esm/types/radiobtn.d.ts +72 -0
  209. package/lib/esm/types/rating.d.ts +53 -0
  210. package/lib/esm/types/request.d.ts +52 -0
  211. package/lib/esm/types/router.d.ts +42 -0
  212. package/lib/esm/types/settings.d.ts +37 -0
  213. package/lib/esm/types/sidebarview.d.ts +49 -0
  214. package/lib/esm/types/spreadsheet.d.ts +218 -0
  215. package/lib/esm/types/styles.d.ts +85 -0
  216. package/lib/esm/types/svgcomponent.d.ts +191 -0
  217. package/lib/esm/types/tabbar.d.ts +58 -0
  218. package/lib/esm/types/tabview.d.ts +49 -0
  219. package/lib/{texthiliter.d.ts → esm/types/textarea.d.ts} +26 -23
  220. package/lib/esm/types/textedit.d.ts +123 -0
  221. package/lib/esm/types/toaster.d.ts +42 -0
  222. package/lib/esm/types/tools.d.ts +394 -0
  223. package/lib/esm/types/tooltips.d.ts +46 -0
  224. package/lib/esm/types/treeview.d.ts +132 -0
  225. package/lib/esm/types/version.d.ts +29 -0
  226. package/lib/esm/types/x4dom.d.ts +49 -0
  227. package/lib/{x4_events.d.ts → esm/types/x4events.d.ts} +6 -3
  228. package/lib/esm/types/x4react.d.ts +41 -0
  229. package/lib/esm/version.js +29 -0
  230. package/lib/esm/x4dom.js +29 -0
  231. package/lib/{x4_events.js → esm/x4events.js} +11 -24
  232. package/lib/esm/x4react.js +71 -0
  233. package/lib/{x4.css → styles/x4.css} +0 -0
  234. package/{src → lib/styles}/x4.less +0 -0
  235. package/package.json +35 -14
  236. package/build.sh +0 -5
  237. package/lib/base64.js +0 -143
  238. package/lib/hosts/host.d.ts +0 -44
  239. package/lib/hosts/host.js +0 -73
  240. package/lib/smartedit.d.ts +0 -107
  241. package/lib/smartedit.js +0 -390
  242. package/lib/texthiliter.js +0 -227
  243. package/src/MIT-license.md +0 -14
  244. package/src/action.ts +0 -88
  245. package/src/alpha.jpg +0 -0
  246. package/src/application.ts +0 -251
  247. package/src/autocomplete.ts +0 -197
  248. package/src/base64.ts +0 -166
  249. package/src/base_component.ts +0 -152
  250. package/src/button.ts +0 -355
  251. package/src/calendar.ts +0 -322
  252. package/src/canvas.ts +0 -505
  253. package/src/cardview.ts +0 -227
  254. package/src/checkbox.ts +0 -187
  255. package/src/color.ts +0 -752
  256. package/src/colorpicker.ts +0 -1639
  257. package/src/combobox.ts +0 -362
  258. package/src/component.ts +0 -2329
  259. package/src/datastore.ts +0 -1322
  260. package/src/dialog.ts +0 -656
  261. package/src/dom_events.ts +0 -315
  262. package/src/drag_manager.ts +0 -199
  263. package/src/drawtext.ts +0 -355
  264. package/src/fileupload.ts +0 -213
  265. package/src/form.ts +0 -366
  266. package/src/formatters.ts +0 -105
  267. package/src/gridview.ts +0 -1185
  268. package/src/i18n.ts +0 -346
  269. package/src/icon.ts +0 -329
  270. package/src/image.ts +0 -204
  271. package/src/index.ts +0 -88
  272. package/src/input.ts +0 -249
  273. package/src/label.ts +0 -128
  274. package/src/layout.ts +0 -430
  275. package/src/link.ts +0 -86
  276. package/src/listview.ts +0 -762
  277. package/src/menu.ts +0 -425
  278. package/src/messagebox.ts +0 -203
  279. package/src/panel.ts +0 -86
  280. package/src/popup.ts +0 -494
  281. package/src/property_editor.ts +0 -337
  282. package/src/radiobtn.ts +0 -196
  283. package/src/rating.ts +0 -135
  284. package/src/request.ts +0 -300
  285. package/src/router.ts +0 -185
  286. package/src/settings.ts +0 -77
  287. package/src/sidebarview.ts +0 -103
  288. package/src/spreadsheet.ts +0 -1442
  289. package/src/styles.ts +0 -343
  290. package/src/svgcomponent.ts +0 -537
  291. package/src/tabbar.ts +0 -151
  292. package/src/tabview.ts +0 -110
  293. package/src/textarea.ts +0 -187
  294. package/src/textedit.ts +0 -544
  295. package/src/toaster.ts +0 -80
  296. package/src/tools.ts +0 -1468
  297. package/src/tooltips.ts +0 -191
  298. package/src/treeview.ts +0 -675
  299. package/src/version.ts +0 -30
  300. package/src/x4dom.ts +0 -57
  301. package/src/x4events.ts +0 -585
  302. package/src/x4react.ts +0 -90
  303. package/tsconfig.json +0 -21
@@ -0,0 +1,889 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file gridview.ts
9
+ * @author Etienne Cochard
10
+ *
11
+ * Copyright (c) 2019-2022 R-libre ingenierie
12
+ *
13
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ * of this software and associated documentation files (the "Software"), to deal
15
+ * in the Software without restriction, including without limitation the rights
16
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
+ * of the Software, and to permit persons to whom the Software is furnished to do so,
18
+ * subject to the following conditions:
19
+ * The above copyright notice and this permission notice shall be included in all copies
20
+ * or substantial portions of the Software.
21
+ *
22
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ **/
29
+ const T_UPDATE = Symbol('update');
30
+ /**
31
+ * todo: sizable column
32
+ * todo: button in a column
33
+ */
34
+ import { x4document } from './x4dom';
35
+ import { HLayout, VLayout } from './layout';
36
+ import { Component, EvDblClick, flyWrap, html, SizerOverlay, Flex } from './component';
37
+ import { Label } from './label';
38
+ import { _tr } from './i18n';
39
+ import { downloadData, isFunction } from './tools';
40
+ import { DataStore } from './datastore';
41
+ import { EvContextMenu, EvSelectionChange, BasicEvent } from "./x4events";
42
+ import { Icon } from './icon.js';
43
+ export function EvGridCheck(rec, chk) {
44
+ return BasicEvent({ rec, chk });
45
+ }
46
+ class ColHeader extends Component {
47
+ m_sens;
48
+ m_sorted;
49
+ constructor(props, title) {
50
+ super(props);
51
+ this.m_sorted = false;
52
+ this.m_sens = 'dn';
53
+ this.setContent([
54
+ new Component({
55
+ tag: 'span',
56
+ content: title
57
+ }),
58
+ new Icon({
59
+ ref: 'sorter',
60
+ cls: '@hidden sort',
61
+ icon: 'var( --x4-icon-arrow-down )'
62
+ })
63
+ ]);
64
+ }
65
+ get sorted() {
66
+ return this.m_sorted;
67
+ }
68
+ //set sorted( v ) {
69
+ // this.m_sorted = v;
70
+ // this.m_sens = 'dn';
71
+ // this.itemWithRef<Icon>( 'sorter' ).show( v );
72
+ //}
73
+ sort(v, sens) {
74
+ this.m_sorted = v;
75
+ this.m_sens = sens;
76
+ const ic = this.itemWithRef('sorter');
77
+ ic.icon = this.m_sens == 'up' ? 'var( --x4-icon-arrow-down )' : 'var( --x4-icon-arrow-up )';
78
+ ic.show(v);
79
+ }
80
+ get sens() {
81
+ return this.m_sens;
82
+ }
83
+ toggleSens() {
84
+ this.m_sens = this.m_sens == 'up' ? 'dn' : 'up';
85
+ this.itemWithRef('sorter').icon = this.m_sens == 'up' ? 'var( --x4-icon-arrow-down )' : 'var( --x4-icon-arrow-up )';
86
+ }
87
+ }
88
+ /**
89
+ * gridview class
90
+ */
91
+ export class GridView extends VLayout {
92
+ m_dataview;
93
+ m_data_cx;
94
+ m_columns;
95
+ m_view_el;
96
+ m_container;
97
+ m_header;
98
+ m_footer;
99
+ m_empty_msg;
100
+ m_empty_text;
101
+ m_selection;
102
+ m_itemHeight;
103
+ m_topIndex;
104
+ m_visible_rows; // shown elements
105
+ m_hasMarks;
106
+ m_marks; // checked elements
107
+ m_recycler;
108
+ m_rowClassifier;
109
+ constructor(props) {
110
+ super(props);
111
+ this.m_columns = props.columns;
112
+ this.m_hasMarks = props.hasMarks ?? false;
113
+ this.m_marks = new Set();
114
+ // prepend the checkable column
115
+ if (this.m_hasMarks) {
116
+ this.m_columns.unshift({
117
+ id: 'id',
118
+ title: '',
119
+ width: 30,
120
+ renderer: (e) => this._renderCheck(e)
121
+ });
122
+ }
123
+ this.setAttribute('tabindex', 0);
124
+ this.m_topIndex = 0;
125
+ this.m_itemHeight = 0;
126
+ this.m_recycler = [];
127
+ this.m_rowClassifier = props.calcRowClass;
128
+ this.m_empty_text = props.empty_text ?? _tr.global.empty_list;
129
+ //this.setDomEvent('create', this._handleCreate, this);
130
+ this.setDomEvent('click', (e) => this._itemClick(e));
131
+ this.setDomEvent('dblclick', (e) => this._itemDblClick(e));
132
+ this.setDomEvent('contextmenu', (e) => this._itemMenu(e));
133
+ this.setDomEvent('keydown', (e) => this._handleKey(e));
134
+ this.setStore(props.store);
135
+ }
136
+ componentCreated() {
137
+ this._updateScroll(true);
138
+ }
139
+ /**
140
+ *
141
+ */
142
+ _moveSel(sens, select = true) {
143
+ let sel = this.m_selection;
144
+ let scrolltype = null;
145
+ if (sel === undefined) {
146
+ sel = this.m_dataview.getByIndex(0).getID();
147
+ }
148
+ else {
149
+ let index = this.m_dataview.indexOfId(this.m_selection);
150
+ if (sens == 1) {
151
+ index++;
152
+ }
153
+ else if (sens == -1) {
154
+ index--;
155
+ }
156
+ else if (sens == 2) {
157
+ index += this.m_visible_rows.length - 1;
158
+ }
159
+ else if (sens == -2) {
160
+ index -= this.m_visible_rows.length - 1;
161
+ }
162
+ if (sens < 0) {
163
+ scrolltype = 'start';
164
+ }
165
+ else {
166
+ scrolltype = 'end';
167
+ }
168
+ if (index < 0) {
169
+ index = 0;
170
+ }
171
+ else if (index >= this.m_dataview.count) {
172
+ index = this.m_dataview.count - 1;
173
+ }
174
+ sel = this.m_dataview.getByIndex(index).getID();
175
+ }
176
+ if (this.m_selection != sel && select) {
177
+ this._selectItem(sel, null, scrolltype);
178
+ }
179
+ return sel;
180
+ }
181
+ /**
182
+ *
183
+ */
184
+ _handleKey(event) {
185
+ if (!this.m_dataview || this.m_dataview.count == 0) {
186
+ return;
187
+ }
188
+ switch (event.key) {
189
+ case 'ArrowDown':
190
+ case 'Down': {
191
+ this._moveSel(1);
192
+ break;
193
+ }
194
+ case 'ArrowUp':
195
+ case 'Up': {
196
+ this._moveSel(-1);
197
+ break;
198
+ }
199
+ case 'PageUp': {
200
+ this._moveSel(-2);
201
+ break;
202
+ }
203
+ case 'PageDown': {
204
+ this._moveSel(2);
205
+ break;
206
+ }
207
+ }
208
+ }
209
+ /**
210
+ *
211
+ */
212
+ getNextSel(sens) {
213
+ return this._moveSel(sens, false);
214
+ }
215
+ _scrollIntoView(id, sens) {
216
+ let itm = this._findItem(id);
217
+ if (itm) {
218
+ itm.scrollIntoView({
219
+ block: 'center' //<ScrollLogicalPosition>sens ?? 'nearest'
220
+ });
221
+ }
222
+ else {
223
+ this.m_topIndex = this.m_dataview.indexOfId(id);
224
+ this.m_view_el.dom.scrollTop = this.m_topIndex * this.m_itemHeight;
225
+ this._buildItems();
226
+ this._scrollIntoView(id);
227
+ }
228
+ }
229
+ /**
230
+ * change the list of item displayed
231
+ * @param items - new array of items
232
+ */
233
+ setStore(store) {
234
+ this.m_selection = undefined;
235
+ if (store instanceof DataStore) {
236
+ this.m_dataview = store.createView();
237
+ }
238
+ else {
239
+ this.m_dataview = store;
240
+ }
241
+ if (this.m_hasMarks) {
242
+ this.clearMarks();
243
+ }
244
+ // unlink previous observer
245
+ if (this.m_data_cx) {
246
+ this.m_data_cx.dispose();
247
+ }
248
+ if (this.m_dataview) {
249
+ this.m_data_cx = this.m_dataview.on('view_change', (ev) => {
250
+ if (ev.action == 'change') {
251
+ this.m_selection = undefined;
252
+ }
253
+ this._updateScroll(true);
254
+ });
255
+ //this.update( );
256
+ this._updateScroll(true);
257
+ }
258
+ }
259
+ getView() {
260
+ return this.m_dataview;
261
+ }
262
+ /**
263
+ * return the current selection (row id) or null
264
+ */
265
+ getSelection() {
266
+ return this.m_selection;
267
+ }
268
+ getSelRec() {
269
+ if (this.m_selection) {
270
+ return this.m_dataview.getById(this.m_selection);
271
+ }
272
+ return null;
273
+ }
274
+ setSelection(recId) {
275
+ this._selectItem(recId, null, 'center');
276
+ }
277
+ /** @ignore */
278
+ render() {
279
+ this.m_recycler = [];
280
+ this.m_container = new Component({
281
+ cls: 'content',
282
+ });
283
+ this.m_empty_msg = new Label({
284
+ cls: 'empty-msg',
285
+ text: ''
286
+ });
287
+ this.m_view_el = new Component({
288
+ cls: '@scroll-view',
289
+ flex: 1,
290
+ dom_events: {
291
+ sizechange: () => this._updateScroll(true),
292
+ scroll: () => this._updateScroll(false)
293
+ },
294
+ content: this.m_container
295
+ });
296
+ let flex = false;
297
+ let cols = this.m_columns.map((col, index) => {
298
+ let cls = '@cell';
299
+ if (col.cls) {
300
+ cls += ' ' + col.cls;
301
+ }
302
+ let comp = new ColHeader({
303
+ cls,
304
+ flex: col.flex,
305
+ sizable: 'right',
306
+ style: {
307
+ width: col.width
308
+ },
309
+ dom_events: {
310
+ click: (ev) => {
311
+ let t = flyWrap(ev.target);
312
+ if (!t.hasClass('@sizer-overlay')) { // avoid sizer click
313
+ this._sortCol(col);
314
+ ev.preventDefault();
315
+ }
316
+ }
317
+ }
318
+ }, col.title);
319
+ const resizeCol = (ev) => {
320
+ this._on_col_resize(index, ev.size.width);
321
+ if (this.m_footer) {
322
+ let col = Component.getElement(this.m_footer.dom.childNodes[index]);
323
+ if (col) {
324
+ col.setStyleValue('width', ev.size.width);
325
+ }
326
+ }
327
+ };
328
+ new SizerOverlay({
329
+ target: comp,
330
+ sens: 'right',
331
+ events: { resize: (e) => resizeCol(e) }
332
+ });
333
+ if (col.flex) {
334
+ flex = true;
335
+ }
336
+ col.$hdr = comp;
337
+ return comp;
338
+ });
339
+ cols.push(new Flex({
340
+ ref: 'flex',
341
+ cls: flex ? '@hidden' : ''
342
+ }));
343
+ // compute full width
344
+ let full_width = 0;
345
+ this.m_columns.forEach((col) => {
346
+ full_width += col.width ?? 0;
347
+ });
348
+ this.m_header = new HLayout({
349
+ cls: '@header',
350
+ content: cols,
351
+ style: {
352
+ minWidth: full_width
353
+ }
354
+ });
355
+ if (this.m_props.hasFooter) {
356
+ let foots = this.m_columns.map((col, index) => {
357
+ let cls = '@cell';
358
+ if (col.align) {
359
+ cls += ' ' + col.align;
360
+ }
361
+ if (col.cls) {
362
+ cls += ' ' + col.cls;
363
+ }
364
+ let comp = new Component({
365
+ cls,
366
+ data: { col: index },
367
+ flex: col.flex,
368
+ style: {
369
+ width: col.width
370
+ }
371
+ });
372
+ col.$ftr = comp;
373
+ return comp;
374
+ });
375
+ foots.push(new Flex({
376
+ ref: 'flex',
377
+ cls: flex ? '@hidden' : ''
378
+ }));
379
+ this.m_footer = new HLayout({
380
+ cls: '@footer',
381
+ content: foots,
382
+ style: {
383
+ minWidth: full_width
384
+ }
385
+ });
386
+ }
387
+ else {
388
+ this.m_footer = null;
389
+ }
390
+ this.setContent([
391
+ this.m_header,
392
+ this.m_view_el,
393
+ this.m_footer,
394
+ this.m_empty_msg,
395
+ ]);
396
+ }
397
+ _on_col_resize(col, width) {
398
+ const _col = this.m_columns[col];
399
+ let updateFlex = false;
400
+ if (width >= 0) {
401
+ _col.width = width;
402
+ if (_col.flex) {
403
+ _col.$hdr.removeClass('@flex');
404
+ _col.$ftr?.removeClass('@flex');
405
+ _col.flex = undefined;
406
+ updateFlex = true;
407
+ }
408
+ }
409
+ else if (width < 0 && !_col.flex) {
410
+ _col.$hdr.addClass('@flex');
411
+ _col.$ftr?.addClass('@flex');
412
+ _col.flex = 1;
413
+ updateFlex = true;
414
+ }
415
+ if (updateFlex) {
416
+ let flex = false;
417
+ this.m_columns.forEach(c => {
418
+ if (c.flex) {
419
+ flex = true;
420
+ }
421
+ });
422
+ this.m_header.itemWithRef('flex')?.show(flex ? false : true);
423
+ if (this.m_footer) {
424
+ this.m_footer.itemWithRef('flex')?.show(flex ? false : true);
425
+ }
426
+ }
427
+ this._updateScroll(true);
428
+ }
429
+ /**
430
+ *
431
+ */
432
+ sortCol(name, asc = true) {
433
+ const col = this.m_columns.find(c => c.id == name);
434
+ if (col === undefined) {
435
+ console.assert(false, "unknown field " + name + " in grid.sortCol");
436
+ return;
437
+ }
438
+ this._sortCol(col, asc ? "dn" : "up");
439
+ }
440
+ /**
441
+ *
442
+ */
443
+ _sortCol(col, sens = "up") {
444
+ if (col.sortable === false) {
445
+ return;
446
+ }
447
+ this.m_columns.forEach((c) => {
448
+ if (c !== col) {
449
+ c.$hdr.sort(false, "dn");
450
+ }
451
+ });
452
+ const $hdr = col.$hdr;
453
+ if ($hdr.sorted) {
454
+ $hdr.toggleSens();
455
+ }
456
+ else {
457
+ $hdr.sort(true, sens);
458
+ }
459
+ if (this.m_dataview) {
460
+ this.m_dataview.sort([
461
+ { field: col.id, ascending: $hdr.sens == 'dn' ? false : true }
462
+ ]);
463
+ }
464
+ }
465
+ /**
466
+ *
467
+ */
468
+ _computeItemHeight() {
469
+ let gr = x4document.createElement('div');
470
+ gr.classList.add('x-row');
471
+ let gv = x4document.createElement('div');
472
+ gv.classList.add('x-grid-view');
473
+ gv.style.position = 'absolute';
474
+ gv.style.top = '-1000px';
475
+ gv.appendChild(gr);
476
+ this.dom.appendChild(gv);
477
+ let rc = gr.getBoundingClientRect();
478
+ this.dom.removeChild(gv);
479
+ this.m_itemHeight = rc.height;
480
+ }
481
+ _createRow(props) {
482
+ let row;
483
+ if (this.m_recycler.length) {
484
+ row = this.m_recycler.pop();
485
+ row.clearClasses();
486
+ row.addClass(props.cls);
487
+ row.setContent(props.content);
488
+ row.setStyle(props.style);
489
+ for (let n in props.data) {
490
+ row.setData(n, props.data[n]);
491
+ }
492
+ }
493
+ else {
494
+ row = new HLayout(props);
495
+ }
496
+ if (!row.dom) {
497
+ this.m_container.appendChild(row);
498
+ }
499
+ return row;
500
+ }
501
+ _buildItems(canOpt = true) {
502
+ let rc = this.getBoundingRect();
503
+ let rh = this.m_header.getBoundingRect();
504
+ let height = rc.height - rh.height + this.m_itemHeight;
505
+ if (this.m_itemHeight == 0) {
506
+ this._computeItemHeight();
507
+ }
508
+ let top = this.m_topIndex * this.m_itemHeight;
509
+ let y = 0;
510
+ let cidx = 0;
511
+ let index = this.m_topIndex;
512
+ let count = this.m_dataview ? this.m_dataview.count : 0;
513
+ let full_width = 0; // todo: +4 pixel of left border
514
+ let even = this.m_topIndex & 1 ? true : false;
515
+ // compute full width
516
+ this.m_columns.forEach((col) => {
517
+ full_width += col.width ?? 0;
518
+ });
519
+ // if items height make scroll visible, update header width
520
+ if (((count + 1) * this.m_itemHeight) >= height) {
521
+ let w = Component.getScrollbarSize();
522
+ this.m_header.setStyleValue("paddingRight", w);
523
+ this.m_footer?.setStyleValue("paddingRight", w);
524
+ }
525
+ else {
526
+ this.m_header.setStyleValue("paddingRight", 0);
527
+ this.m_footer?.setStyleValue("paddingRight", 0);
528
+ }
529
+ // passe 0 - all created cells are moved to the recycler
530
+ if (this.m_visible_rows) {
531
+ this.m_visible_rows.forEach((c) => {
532
+ this.m_recycler.push(c);
533
+ });
534
+ }
535
+ this.m_visible_rows = [];
536
+ let limit = 100;
537
+ while (y < height && index < count && --limit > 0) {
538
+ let rec = this.m_dataview.getByIndex(index);
539
+ let rowid = rec.getID();
540
+ let crow = canOpt ? this.m_recycler.findIndex((r) => r.getData('row-id') == rowid) : -1;
541
+ if (crow >= 0) {
542
+ let rrow = this.m_recycler.splice(crow, 1)[0];
543
+ rrow.setStyle({
544
+ top: y + top,
545
+ minWidth: full_width,
546
+ });
547
+ if (this.m_hasMarks) {
548
+ rrow.setClass('@marked', this.m_marks.has(rowid));
549
+ }
550
+ rrow.removeClass('@hidden');
551
+ rrow.setClass('@selected', this.m_selection === rowid);
552
+ this.m_visible_rows[cidx] = rrow;
553
+ }
554
+ else {
555
+ let cols = this.m_columns.map(col => {
556
+ let cls = '@cell';
557
+ if (col.align) {
558
+ cls += ' ' + col.align;
559
+ }
560
+ if (col.cls) {
561
+ cls += ' ' + col.cls;
562
+ }
563
+ let cell;
564
+ if (col.renderer) {
565
+ cell = col.renderer(rec);
566
+ if (cell) {
567
+ cell.addClass(cls);
568
+ cell.setStyleValue('width', col.width);
569
+ if (col.flex !== undefined) {
570
+ cell.addClass('@flex');
571
+ cell.setStyleValue('flex', col.flex);
572
+ }
573
+ }
574
+ }
575
+ else {
576
+ let fmt = col.formatter;
577
+ let text;
578
+ if (fmt && fmt instanceof Function) {
579
+ text = fmt(rec.getRaw(col.id), rec);
580
+ }
581
+ else {
582
+ text = rec.getField(col.id);
583
+ }
584
+ cell = new Component({
585
+ cls,
586
+ width: col.width,
587
+ content: html `<span>${text}</span>`,
588
+ flex: col.flex
589
+ });
590
+ }
591
+ return cell;
592
+ });
593
+ let cls = '@row @hlayout center';
594
+ if (this.m_hasMarks) {
595
+ if (this.m_marks.has(rowid)) {
596
+ cls += ' @marked';
597
+ }
598
+ }
599
+ if (this.m_selection === rowid) {
600
+ cls += ' @selected';
601
+ }
602
+ let row = this.m_visible_rows[cidx] = this._createRow({
603
+ cls,
604
+ content: cols,
605
+ style: {
606
+ top: y + top,
607
+ minWidth: full_width,
608
+ },
609
+ data: {
610
+ 'row-id': rowid,
611
+ 'row-idx': index
612
+ }
613
+ });
614
+ row.addClass(even ? 'even' : 'odd');
615
+ even = !even;
616
+ if (this.m_rowClassifier) {
617
+ this.m_rowClassifier(rec, row);
618
+ }
619
+ }
620
+ y += this.m_itemHeight;
621
+ index++;
622
+ cidx++;
623
+ }
624
+ // if some cells are still in cache, hide them
625
+ this.m_recycler.forEach((c) => {
626
+ c.addClass('@hidden');
627
+ });
628
+ //this.m_container.setContent(<ComponentContent>this.m_visible_rows);
629
+ let show = !count;
630
+ let msg = (this.m_empty_text instanceof Function) ? this.m_empty_text() : this.m_empty_text;
631
+ this.m_empty_msg.text = msg;
632
+ if (show && msg.length == 0) {
633
+ show = false;
634
+ }
635
+ this.m_empty_msg.show(show);
636
+ if (full_width < rc.width) {
637
+ this.m_header.setStyleValue('width', null);
638
+ this.m_footer?.setStyleValue('width', null);
639
+ this.m_container.setStyle({
640
+ height: count * this.m_itemHeight,
641
+ width: null
642
+ });
643
+ }
644
+ else {
645
+ this.m_header.setStyleValue('width', full_width + 1000);
646
+ this.m_footer?.setStyleValue('width', full_width + 1000);
647
+ this.m_container.setStyle({
648
+ height: count * this.m_itemHeight,
649
+ width: full_width
650
+ });
651
+ }
652
+ }
653
+ /**
654
+ *
655
+ */
656
+ _updateScroll(forceUpdate) {
657
+ if (!this.m_view_el || !this.m_view_el.dom) {
658
+ return;
659
+ }
660
+ const update = () => {
661
+ // element destroyed between updateScroll and now
662
+ if (!this.dom) {
663
+ return;
664
+ }
665
+ let newTop = Math.floor(this.m_view_el.dom.scrollTop / (this.m_itemHeight || 1));
666
+ if (newTop != this.m_topIndex || forceUpdate) {
667
+ this.m_topIndex = newTop;
668
+ this._buildItems(!forceUpdate);
669
+ }
670
+ let newLeft = this.m_view_el.dom.scrollLeft;
671
+ this.m_header.setStyleValue('left', -newLeft);
672
+ this.m_footer?.setStyleValue('left', -newLeft);
673
+ };
674
+ if (forceUpdate) {
675
+ this.singleShot(update, 10);
676
+ }
677
+ else {
678
+ update();
679
+ }
680
+ }
681
+ /** @ignore */
682
+ _rowFromTarget(dom) {
683
+ let self = this.dom;
684
+ while (dom && dom != self) {
685
+ let itm = Component.getElement(dom);
686
+ if (itm) {
687
+ let id = itm.getData('row-id');
688
+ if (id !== undefined) {
689
+ return { id, itm };
690
+ }
691
+ }
692
+ dom = dom.parentElement;
693
+ }
694
+ return undefined;
695
+ }
696
+ _itemClick(e) {
697
+ let hit = this._rowFromTarget(e.target);
698
+ if (hit) {
699
+ this._selectItem(hit.id, hit.itm);
700
+ }
701
+ else {
702
+ this._selectItem(undefined, undefined);
703
+ }
704
+ }
705
+ _itemDblClick(e) {
706
+ let hit = this._rowFromTarget(e.target);
707
+ if (hit) {
708
+ this._selectItem(hit.id, hit.itm);
709
+ let rec = this.m_dataview.getById(hit.id);
710
+ this.emit('dblClick', EvDblClick(rec));
711
+ if (this.m_hasMarks) {
712
+ this._toggleMark(rec);
713
+ }
714
+ }
715
+ }
716
+ /** @ignore */
717
+ _itemMenu(e) {
718
+ let dom = e.target, self = this.dom;
719
+ while (dom && dom != self) {
720
+ let itm = Component.getElement(dom), id = itm?.getData('row-id');
721
+ if (id !== undefined) {
722
+ this._selectItem(id, itm);
723
+ let idx = itm.getData('row-idx');
724
+ let rec = this.m_dataview.getByIndex(idx);
725
+ this._showItemContextMenu(e, rec);
726
+ e.preventDefault();
727
+ return;
728
+ }
729
+ dom = dom.parentElement;
730
+ }
731
+ }
732
+ /**
733
+ *
734
+ */
735
+ _findItem(id) {
736
+ for (let i = 0; i < this.m_visible_rows.length; i++) {
737
+ let itm = this.m_visible_rows[i];
738
+ if (itm.getData('row-id') === id) {
739
+ return itm;
740
+ }
741
+ }
742
+ return null;
743
+ }
744
+ /**
745
+ * @ignore
746
+ * called when an item is selected by mouse
747
+ */
748
+ _selectItem(item, dom_item, scrollIntoView) {
749
+ if (this.m_selection !== undefined) {
750
+ let old = this._findItem(this.m_selection);
751
+ if (old) {
752
+ old.removeClass('@selected');
753
+ }
754
+ }
755
+ this.m_selection = item;
756
+ if (item) {
757
+ if (scrollIntoView) {
758
+ this._scrollIntoView(item, scrollIntoView);
759
+ }
760
+ if (!dom_item) {
761
+ dom_item = this._findItem(item);
762
+ }
763
+ if (dom_item) {
764
+ dom_item.addClass('@selected');
765
+ }
766
+ let rec = this.m_dataview.getById(item);
767
+ this.emit('selectionChange', EvSelectionChange(rec));
768
+ }
769
+ else {
770
+ this.emit('selectionChange', EvSelectionChange(null));
771
+ }
772
+ }
773
+ /**
774
+ *
775
+ */
776
+ _showItemContextMenu(event, item) {
777
+ this.emit('contextMenu', EvContextMenu(event, item));
778
+ }
779
+ /**
780
+ *
781
+ */
782
+ clearSelection() {
783
+ this._selectItem(null, null);
784
+ }
785
+ /**
786
+ * todo: moveto datastore
787
+ */
788
+ exportData(filename) {
789
+ let data = '';
790
+ const fsep = '\t';
791
+ const lsep = '\r\n';
792
+ let rec = '';
793
+ this.m_columns.map((col) => {
794
+ if (rec.length) {
795
+ rec += fsep;
796
+ }
797
+ rec += col.title;
798
+ });
799
+ data += rec + lsep;
800
+ let count = this.m_dataview.count;
801
+ for (let i = 0; i < count; i++) {
802
+ let record = this.m_dataview.getByIndex(i);
803
+ rec = '';
804
+ let cols = this.m_columns.map((col) => {
805
+ let text = record.getField(col.id);
806
+ let fmt = col.formatter;
807
+ if (fmt && fmt instanceof Function) {
808
+ text = fmt(text, record);
809
+ }
810
+ if (rec.length > 0) {
811
+ rec += fsep;
812
+ }
813
+ rec += text;
814
+ });
815
+ data += rec + lsep;
816
+ }
817
+ //todo: review that
818
+ data = data.replace(/[àâä]/gm, 'a');
819
+ data = data.replace(/[éèê]/gm, 'e');
820
+ data = data.replace(/[îï]/gm, 'i');
821
+ data = data.replace(/[ûüù]/gm, 'u');
822
+ data = data.replace(/ /gm, ' '); // non breaking space
823
+ downloadData(data, 'text/csv', filename);
824
+ }
825
+ set empty_text(text) {
826
+ this.m_empty_msg.text = text;
827
+ }
828
+ _renderCheck(rec) {
829
+ let icon = '--x4-icon-square';
830
+ if (this.m_marks.has(rec.getID())) {
831
+ icon = '--x4-icon-square-check';
832
+ }
833
+ return new Icon({ icon: `var(${icon})` });
834
+ }
835
+ _toggleMark(rec) {
836
+ let id = rec.getID();
837
+ let chk = false;
838
+ if (this.m_marks.has(id)) {
839
+ this.m_marks.delete(id);
840
+ }
841
+ else {
842
+ this.m_marks.add(id);
843
+ chk = true;
844
+ }
845
+ this.emit('gridCheck', EvGridCheck(rec, chk));
846
+ this._buildItems(false);
847
+ }
848
+ getMarks() {
849
+ let ids = [];
850
+ for (const v of this.m_marks.values()) {
851
+ ids.push(v);
852
+ }
853
+ return ids;
854
+ }
855
+ clearMarks() {
856
+ if (this.m_marks.size) {
857
+ this.m_marks = new Set();
858
+ this._buildItems(false);
859
+ }
860
+ }
861
+ setFooterData(rec) {
862
+ if (!this.m_footer) {
863
+ return;
864
+ }
865
+ this.m_footer.enumChilds((c) => {
866
+ let cid = c.getData('col');
867
+ if (cid) {
868
+ let col = this.m_columns[cid];
869
+ let value = rec[col.id];
870
+ if (value !== undefined) {
871
+ if (isFunction(value)) { // FooterRenderer
872
+ value(c);
873
+ }
874
+ else {
875
+ let text;
876
+ const fmt = col.formatter;
877
+ if (fmt && fmt instanceof Function) {
878
+ text = fmt(value, rec);
879
+ }
880
+ else {
881
+ text = value;
882
+ }
883
+ c.setContent(text, false);
884
+ }
885
+ }
886
+ }
887
+ });
888
+ }
889
+ }