libre-jqgrid 4.17.2 → 4.17.4

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 (211) hide show
  1. package/.tscache/all/hashes/free-jqgrid.d.ts-74303c8b076937117540c0cb798f2053 +1 -0
  2. package/.tscache/all/hashes/test.ts-0d81877a31bc5d7ac52dd35a66602f01 +1 -0
  3. package/.tscache/all/timestamp +0 -0
  4. package/dist/css/ui.jqgrid.css +1618 -0
  5. package/dist/css/ui.jqgrid.min.css +4 -0
  6. package/dist/css/ui.jqgrid.min.css.map +1 -0
  7. package/dist/i18n/grid.locale-ar.js +198 -0
  8. package/dist/i18n/grid.locale-bg.js +201 -0
  9. package/dist/i18n/grid.locale-bs.js +230 -0
  10. package/dist/i18n/grid.locale-ca.js +204 -0
  11. package/dist/i18n/grid.locale-cn.js +237 -0
  12. package/dist/i18n/grid.locale-cs.js +197 -0
  13. package/dist/i18n/grid.locale-da.js +196 -0
  14. package/dist/i18n/grid.locale-de.js +240 -0
  15. package/dist/i18n/grid.locale-el.js +195 -0
  16. package/dist/i18n/grid.locale-en.js +256 -0
  17. package/dist/i18n/grid.locale-es.js +202 -0
  18. package/dist/i18n/grid.locale-fa.js +211 -0
  19. package/dist/i18n/grid.locale-fi.js +201 -0
  20. package/dist/i18n/grid.locale-fr.js +197 -0
  21. package/dist/i18n/grid.locale-gl.js +197 -0
  22. package/dist/i18n/grid.locale-he.js +198 -0
  23. package/dist/i18n/grid.locale-hr.js +231 -0
  24. package/dist/i18n/grid.locale-hu.js +196 -0
  25. package/dist/i18n/grid.locale-id.js +238 -0
  26. package/dist/i18n/grid.locale-is.js +197 -0
  27. package/dist/i18n/grid.locale-it.js +189 -0
  28. package/dist/i18n/grid.locale-ja.js +203 -0
  29. package/dist/i18n/grid.locale-kr.js +194 -0
  30. package/dist/i18n/grid.locale-lt.js +199 -0
  31. package/dist/i18n/grid.locale-me.js +198 -0
  32. package/dist/i18n/grid.locale-nl.js +208 -0
  33. package/dist/i18n/grid.locale-no.js +180 -0
  34. package/dist/i18n/grid.locale-pl.js +204 -0
  35. package/dist/i18n/grid.locale-pt-br.js +210 -0
  36. package/dist/i18n/grid.locale-pt.js +196 -0
  37. package/dist/i18n/grid.locale-ro.js +210 -0
  38. package/dist/i18n/grid.locale-ru.js +196 -0
  39. package/dist/i18n/grid.locale-sk.js +198 -0
  40. package/dist/i18n/grid.locale-sl.js +230 -0
  41. package/dist/i18n/grid.locale-sr.js +199 -0
  42. package/dist/i18n/grid.locale-sv.js +198 -0
  43. package/dist/i18n/grid.locale-th.js +195 -0
  44. package/dist/i18n/grid.locale-tr.js +197 -0
  45. package/dist/i18n/grid.locale-tw.js +199 -0
  46. package/dist/i18n/grid.locale-ua.js +199 -0
  47. package/dist/i18n/grid.locale-vi.js +238 -0
  48. package/dist/i18n/min/grid.locale-ar.js +10 -0
  49. package/dist/i18n/min/grid.locale-ar.js.map +1 -0
  50. package/dist/i18n/min/grid.locale-bg.js +10 -0
  51. package/dist/i18n/min/grid.locale-bg.js.map +1 -0
  52. package/dist/i18n/min/grid.locale-ca.js +15 -0
  53. package/dist/i18n/min/grid.locale-ca.js.map +1 -0
  54. package/dist/i18n/min/grid.locale-cn.js +10 -0
  55. package/dist/i18n/min/grid.locale-cn.js.map +1 -0
  56. package/dist/i18n/min/grid.locale-cs.js +11 -0
  57. package/dist/i18n/min/grid.locale-cs.js.map +1 -0
  58. package/dist/i18n/min/grid.locale-da.js +10 -0
  59. package/dist/i18n/min/grid.locale-da.js.map +1 -0
  60. package/dist/i18n/min/grid.locale-de.js +21 -0
  61. package/dist/i18n/min/grid.locale-de.js.map +1 -0
  62. package/dist/i18n/min/grid.locale-el.js +10 -0
  63. package/dist/i18n/min/grid.locale-el.js.map +1 -0
  64. package/dist/i18n/min/grid.locale-en.js +11 -0
  65. package/dist/i18n/min/grid.locale-en.js.map +1 -0
  66. package/dist/i18n/min/grid.locale-es.js +16 -0
  67. package/dist/i18n/min/grid.locale-es.js.map +1 -0
  68. package/dist/i18n/min/grid.locale-fa.js +8 -0
  69. package/dist/i18n/min/grid.locale-fa.js.map +1 -0
  70. package/dist/i18n/min/grid.locale-fi.js +11 -0
  71. package/dist/i18n/min/grid.locale-fi.js.map +1 -0
  72. package/dist/i18n/min/grid.locale-fr.js +10 -0
  73. package/dist/i18n/min/grid.locale-fr.js.map +1 -0
  74. package/dist/i18n/min/grid.locale-gl.js +9 -0
  75. package/dist/i18n/min/grid.locale-gl.js.map +1 -0
  76. package/dist/i18n/min/grid.locale-he.js +10 -0
  77. package/dist/i18n/min/grid.locale-he.js.map +1 -0
  78. package/dist/i18n/min/grid.locale-hr.js +11 -0
  79. package/dist/i18n/min/grid.locale-hr.js.map +1 -0
  80. package/dist/i18n/min/grid.locale-hu.js +10 -0
  81. package/dist/i18n/min/grid.locale-hu.js.map +1 -0
  82. package/dist/i18n/min/grid.locale-id.js +10 -0
  83. package/dist/i18n/min/grid.locale-id.js.map +1 -0
  84. package/dist/i18n/min/grid.locale-is.js +9 -0
  85. package/dist/i18n/min/grid.locale-is.js.map +1 -0
  86. package/dist/i18n/min/grid.locale-it.js +2 -0
  87. package/dist/i18n/min/grid.locale-it.js.map +1 -0
  88. package/dist/i18n/min/grid.locale-ja.js +10 -0
  89. package/dist/i18n/min/grid.locale-ja.js.map +1 -0
  90. package/dist/i18n/min/grid.locale-kr.js +2 -0
  91. package/dist/i18n/min/grid.locale-kr.js.map +1 -0
  92. package/dist/i18n/min/grid.locale-lt.js +10 -0
  93. package/dist/i18n/min/grid.locale-lt.js.map +1 -0
  94. package/dist/i18n/min/grid.locale-me.js +10 -0
  95. package/dist/i18n/min/grid.locale-me.js.map +1 -0
  96. package/dist/i18n/min/grid.locale-nl.js +2 -0
  97. package/dist/i18n/min/grid.locale-nl.js.map +1 -0
  98. package/dist/i18n/min/grid.locale-no.js +2 -0
  99. package/dist/i18n/min/grid.locale-no.js.map +1 -0
  100. package/dist/i18n/min/grid.locale-pl.js +18 -0
  101. package/dist/i18n/min/grid.locale-pl.js.map +1 -0
  102. package/dist/i18n/min/grid.locale-pt-br.js +21 -0
  103. package/dist/i18n/min/grid.locale-pt-br.js.map +1 -0
  104. package/dist/i18n/min/grid.locale-pt.js +9 -0
  105. package/dist/i18n/min/grid.locale-pt.js.map +1 -0
  106. package/dist/i18n/min/grid.locale-ro.js +10 -0
  107. package/dist/i18n/min/grid.locale-ro.js.map +1 -0
  108. package/dist/i18n/min/grid.locale-ru.js +10 -0
  109. package/dist/i18n/min/grid.locale-ru.js.map +1 -0
  110. package/dist/i18n/min/grid.locale-sk.js +10 -0
  111. package/dist/i18n/min/grid.locale-sk.js.map +1 -0
  112. package/dist/i18n/min/grid.locale-sr.js +10 -0
  113. package/dist/i18n/min/grid.locale-sr.js.map +1 -0
  114. package/dist/i18n/min/grid.locale-sv.js +10 -0
  115. package/dist/i18n/min/grid.locale-sv.js.map +1 -0
  116. package/dist/i18n/min/grid.locale-th.js +10 -0
  117. package/dist/i18n/min/grid.locale-th.js.map +1 -0
  118. package/dist/i18n/min/grid.locale-tr.js +10 -0
  119. package/dist/i18n/min/grid.locale-tr.js.map +1 -0
  120. package/dist/i18n/min/grid.locale-tw.js +11 -0
  121. package/dist/i18n/min/grid.locale-tw.js.map +1 -0
  122. package/dist/i18n/min/grid.locale-ua.js +10 -0
  123. package/dist/i18n/min/grid.locale-ua.js.map +1 -0
  124. package/dist/i18n/min/grid.locale-vi.js +10 -0
  125. package/dist/i18n/min/grid.locale-vi.js.map +1 -0
  126. package/dist/jquery.jqgrid.min.js +11 -0
  127. package/dist/jquery.jqgrid.min.js.map +1 -0
  128. package/{js/jquery.jqgrid.src.js.1 → dist/jquery.jqgrid.src.js} +1 -1
  129. package/dist/modules/grid.base.js +8518 -0
  130. package/dist/modules/grid.celledit.js +673 -0
  131. package/dist/modules/grid.common.js +844 -0
  132. package/dist/modules/grid.custom.js +1795 -0
  133. package/dist/modules/grid.filter.js +897 -0
  134. package/dist/modules/grid.formedit.js +2537 -0
  135. package/dist/modules/grid.grouping.js +737 -0
  136. package/dist/modules/grid.import.js +251 -0
  137. package/dist/modules/grid.inlinedit.js +784 -0
  138. package/dist/modules/grid.jqueryui.js +965 -0
  139. package/dist/modules/grid.pivot.js +862 -0
  140. package/dist/modules/grid.subgrid.js +379 -0
  141. package/dist/modules/grid.tbltogrid.js +141 -0
  142. package/dist/modules/grid.treegrid.js +683 -0
  143. package/dist/modules/jqdnr.js +188 -0
  144. package/dist/modules/jqmodal.js +292 -0
  145. package/dist/modules/jquery.fmatter.js +1061 -0
  146. package/dist/modules/jsonxml.js +343 -0
  147. package/dist/modules/min/grid.base.js +11 -0
  148. package/dist/modules/min/grid.base.js.map +1 -0
  149. package/dist/modules/min/grid.celledit.js +2 -0
  150. package/dist/modules/min/grid.celledit.js.map +1 -0
  151. package/dist/modules/min/grid.common.js +2 -0
  152. package/dist/modules/min/grid.common.js.map +1 -0
  153. package/dist/modules/min/grid.custom.js +2 -0
  154. package/dist/modules/min/grid.custom.js.map +1 -0
  155. package/dist/modules/min/grid.filter.js +2 -0
  156. package/dist/modules/min/grid.filter.js.map +1 -0
  157. package/dist/modules/min/grid.formedit.js +2 -0
  158. package/dist/modules/min/grid.formedit.js.map +1 -0
  159. package/dist/modules/min/grid.grouping.js +2 -0
  160. package/dist/modules/min/grid.grouping.js.map +1 -0
  161. package/dist/modules/min/grid.import.js +2 -0
  162. package/dist/modules/min/grid.import.js.map +1 -0
  163. package/dist/modules/min/grid.inlinedit.js +2 -0
  164. package/dist/modules/min/grid.inlinedit.js.map +1 -0
  165. package/dist/modules/min/grid.jqueryui.js +2 -0
  166. package/dist/modules/min/grid.jqueryui.js.map +1 -0
  167. package/dist/modules/min/grid.pivot.js +2 -0
  168. package/dist/modules/min/grid.pivot.js.map +1 -0
  169. package/dist/modules/min/grid.subgrid.js +2 -0
  170. package/dist/modules/min/grid.subgrid.js.map +1 -0
  171. package/dist/modules/min/grid.tbltogrid.js +2 -0
  172. package/dist/modules/min/grid.tbltogrid.js.map +1 -0
  173. package/dist/modules/min/grid.treegrid.js +2 -0
  174. package/dist/modules/min/grid.treegrid.js.map +1 -0
  175. package/dist/modules/min/jqdnr.js +2 -0
  176. package/dist/modules/min/jqdnr.js.map +1 -0
  177. package/dist/modules/min/jqmodal.js +2 -0
  178. package/dist/modules/min/jqmodal.js.map +1 -0
  179. package/dist/modules/min/jquery.fmatter.js +2 -0
  180. package/dist/modules/min/jquery.fmatter.js.map +1 -0
  181. package/dist/modules/min/jsonxml.js +2 -0
  182. package/dist/modules/min/jsonxml.js.map +1 -0
  183. package/dist/plugins/css/ui.multiselect.css +30 -0
  184. package/dist/plugins/css/ui.multiselect.min.css +2 -0
  185. package/dist/plugins/css/ui.multiselect.min.css.map +1 -0
  186. package/dist/plugins/grid.odata.js +1313 -0
  187. package/dist/plugins/jqgrid_download.js +109 -0
  188. package/dist/plugins/jquery.contextmenu-ui.js +304 -0
  189. package/dist/plugins/jquery.contextmenu.js +174 -0
  190. package/dist/plugins/jquery.createcontexmenufromnavigatorbuttons.js +172 -0
  191. package/dist/plugins/jquery.jqgrid.showhidecolumnmenu.js +201 -0
  192. package/dist/plugins/min/grid.odata.js +11 -0
  193. package/dist/plugins/min/grid.odata.js.map +1 -0
  194. package/dist/plugins/min/jquery.contextmenu-ui.js +26 -0
  195. package/dist/plugins/min/jquery.contextmenu-ui.js.map +1 -0
  196. package/dist/plugins/min/jquery.contextmenu.js +19 -0
  197. package/dist/plugins/min/jquery.contextmenu.js.map +1 -0
  198. package/dist/plugins/min/jquery.createcontexmenufromnavigatorbuttons.js +12 -0
  199. package/dist/plugins/min/jquery.createcontexmenufromnavigatorbuttons.js.map +1 -0
  200. package/dist/plugins/min/jquery.jqgrid.showhidecolumnmenu.js +10 -0
  201. package/dist/plugins/min/jquery.jqgrid.showhidecolumnmenu.js.map +1 -0
  202. package/dist/plugins/min/ui.multiselect.js +30 -0
  203. package/dist/plugins/min/ui.multiselect.js.map +1 -0
  204. package/dist/plugins/ui.multiselect.js +389 -0
  205. package/dist/ts/free-jqgrid.d.ts +2132 -0
  206. package/js/jquery.jqgrid.min.js +1 -1
  207. package/js/jquery.jqgrid.min.js.map +1 -1
  208. package/js/jquery.jqgrid.src.js +8 -3
  209. package/libre-jqgrid-4.17.4.tgz +0 -0
  210. package/package.json +1 -1
  211. package/.github/workflows/npm.yml +0 -47
@@ -0,0 +1,683 @@
1
+ /**
2
+ * jqGrid extension - Tree Grid
3
+ * Copyright (c) 2008-2014, Tony Tomov, tony@trirand.com
4
+ * Copyright (c) 2014-2019, Oleg Kiriljuk, oleg.kiriljuk@ok-soft-gmbh.com
5
+ * Copyright (c) 2023, rany2, ranygh@riseup.net
6
+ * Dual licensed under the MIT and GPL licenses:
7
+ * http://www.opensource.org/licenses/mit-license.php
8
+ * http://www.gnu.org/licenses/gpl-2.0.html
9
+ **/
10
+
11
+ /*jshint eqeqeq:false */
12
+ /*jslint browser: true, eqeq: true, plusplus: true, nomen: true, unparam: true, vars: true, white: true, todo: true */
13
+ /*global jQuery, define, exports, module, require */
14
+ (function (factory) {
15
+ "use strict";
16
+ if (typeof define === "function" && define.amd) {
17
+ // AMD. Register as an anonymous module.
18
+ define([
19
+ "jquery",
20
+ "./grid.base"
21
+ ], factory);
22
+ } else if (typeof module === "object" && module.exports) {
23
+ // Node/CommonJS
24
+ module.exports = function (root, $) {
25
+ if (!root) {
26
+ root = window;
27
+ }
28
+ if ($ === undefined) {
29
+ // require("jquery") returns a factory that requires window to
30
+ // build a jQuery instance, we normalize how we use modules
31
+ // that require this pattern but the window provided is a noop
32
+ // if it's defined (how jquery works)
33
+ $ = typeof window !== "undefined" ?
34
+ require("jquery") :
35
+ require("jquery")(root);
36
+ }
37
+ require("./grid.base");
38
+ factory($);
39
+ return $;
40
+ };
41
+ } else {
42
+ // Browser globals
43
+ factory(jQuery);
44
+ }
45
+ }(function ($) {
46
+ "use strict";
47
+ var jgrid = $.jgrid, getAccessor = jgrid.getAccessor, stripPref = jgrid.stripPref,
48
+ jqID = jgrid.jqID, base = $.fn.jqGrid;
49
+ // begin module grid.treegrid
50
+ var treeGridFeedback = function () {
51
+ var args = $.makeArray(arguments);
52
+ args[0] = "treeGrid" + args[0].charAt(0).toUpperCase() + args[0].substring(1);
53
+ args.unshift("");
54
+ args.unshift("");
55
+ args.unshift(this.p);
56
+ return jgrid.feedback.apply(this, args);
57
+ },
58
+ getNodeIcons = function (p, item) {
59
+ var icons = item[p.treeReader.icon_field],
60
+ treeIcons = p.treeIcons,
61
+ iconCollapsed = treeIcons.plus + " tree-plus",
62
+ iconExpanded = treeIcons.minus + " tree-minus";
63
+ if (icons && typeof icons === "string") {
64
+ icons = icons.split(",");
65
+ if (icons.length === 2) {
66
+ iconExpanded = icons[0];
67
+ iconCollapsed = icons[1];
68
+ }
69
+ }
70
+ return {
71
+ expanded: iconExpanded,
72
+ collapsed: iconCollapsed,
73
+ common: treeIcons.commonIconClass
74
+ };
75
+ };
76
+ jgrid.extend({
77
+ setTreeNode: function () {
78
+ // TODO: Move the code in setTreeGrid because it uses currently no parameters
79
+ // and it's don't make any actions with specific row
80
+ return this.each(function () {
81
+ var $t = this, $self = $($t), p = $t.p;
82
+ if (!$t.grid || !p.treeGrid) { return; }
83
+ var expanded = p.treeReader.expanded_field,
84
+ isLeaf = p.treeReader.leaf_field,
85
+ beforeSelectRow = function (e, rowid, eOrg) {
86
+ if (eOrg != null) {
87
+ var $target = $(eOrg.target),
88
+ $td = $target.closest("tr.jqgrow>td"),
89
+ $tr = $td.parent(),
90
+ expendOrCollaps = function () {
91
+ var item = p.data[p._index[stripPref(p.idPrefix, rowid)]],
92
+ collapseOrExpand = item[expanded] ? "collapse" : "expand";
93
+ if (!item[isLeaf]) {
94
+ base[collapseOrExpand + "Row"].call($self, item, $tr);
95
+ base[collapseOrExpand + "Node"].call($self, item, $tr);
96
+ }
97
+ };
98
+ if ($target.is("div.treeclick")) {
99
+ expendOrCollaps();
100
+ } else if (p.ExpandColClick) {
101
+ if ($td.length > 0 && $target.closest("span.cell-wrapper", $td).length > 0) {
102
+ expendOrCollaps();
103
+ }
104
+ }
105
+ return true; // allow selection
106
+ }
107
+ };
108
+
109
+ $self.off("jqGridBeforeSelectRow.setTreeNode");
110
+ $self.on("jqGridBeforeSelectRow.setTreeNode", beforeSelectRow);
111
+
112
+ });
113
+ },
114
+ setTreeGrid: function () {
115
+ return this.each(function () {
116
+ var $t = this, p = $t.p, nm, key, tkey, dupcols = [],
117
+ boolProp = ["leaf_field", "expanded_field", "loaded"];
118
+ if (!p.treeGrid) { return; }
119
+ if (!p.treedatatype) { $.extend($t.p, { treedatatype: p.datatype }); }
120
+ p.subGrid = false;
121
+ p.altRows = false;
122
+ p.pgbuttons = false;
123
+ p.pginput = false;
124
+ p.gridview = true;
125
+ if (p.rowTotal === null) { p.rowNum = p.maxRowNum; }
126
+ p.rowList = [];
127
+ //pico = "ui-icon-triangle-1-" + (p.direction==="rtl" ? "w" : "e");
128
+ //p.treeIcons = $.extend({plus:pico,minus:"ui-icon-triangle-1-s",leaf:"ui-icon-radio-off"},p.treeIcons || {});
129
+ p.treeIcons.plus = p.direction === "rtl" ? p.treeIcons.plusRtl : p.treeIcons.plusLtr;
130
+ if (p.treeGridModel === "nested") {
131
+ p.treeReader = $.extend({
132
+ level_field: "level",
133
+ left_field: "lft",
134
+ right_field: "rgt",
135
+ leaf_field: "isLeaf",
136
+ expanded_field: "expanded",
137
+ loaded: "loaded",
138
+ icon_field: "icon"
139
+ }, p.treeReader);
140
+ } else if (p.treeGridModel === "adjacency") {
141
+ p.treeReader = $.extend({
142
+ level_field: "level",
143
+ parent_id_field: "parent",
144
+ leaf_field: "isLeaf",
145
+ expanded_field: "expanded",
146
+ loaded: "loaded",
147
+ icon_field: "icon"
148
+ }, p.treeReader);
149
+ }
150
+ for (key in p.colModel) {
151
+ if (p.colModel.hasOwnProperty(key)) {
152
+ nm = p.colModel[key].name;
153
+ for (tkey in p.treeReader) {
154
+ if (p.treeReader.hasOwnProperty(tkey) && p.treeReader[tkey] === nm) {
155
+ dupcols.push(nm);
156
+ }
157
+ }
158
+ }
159
+ }
160
+ $.each(p.treeReader, function (prop) {
161
+ var name = String(this);
162
+ if (name && $.inArray(name, dupcols) === -1) {
163
+ if ($.inArray(prop, boolProp) >= 0) {
164
+ p.additionalProperties.push({
165
+ name: name,
166
+ search: false,
167
+ convert: function (data) {
168
+ return data === true || String(data).toLowerCase() === "true" || String(data) === "1" ? true : data;
169
+ }
170
+ });
171
+ } else {
172
+ p.additionalProperties.push(name);
173
+ }
174
+ }
175
+ });
176
+ });
177
+ },
178
+ expandRow: function (record) {
179
+ this.each(function () {
180
+ var $t = this, $self = $($t), p = $t.p;
181
+ if (!$t.grid || !p.treeGrid) { return; }
182
+ var expanded = p.treeReader.expanded_field, rowid = record[p.localReader.id]; // without prefix
183
+ if (!treeGridFeedback.call($t, "beforeExpandRow", { rowid: rowid, item: record })) { return; }
184
+ var childern = base.getNodeChildren.call($self, record);
185
+ $(childern).each(function () {
186
+ var id = p.idPrefix + getAccessor(this, p.localReader.id);
187
+ $(base.getGridRowById.call($self, id)).css("display", "");
188
+ if (this[expanded]) {
189
+ base.expandRow.call($self, this);
190
+ }
191
+ });
192
+ treeGridFeedback.call($t, "afterExpandRow", { rowid: rowid, item: record });
193
+ });
194
+ },
195
+ collapseRow: function (record) {
196
+ this.each(function () {
197
+ var $t = this, $self = $($t), p = $t.p;
198
+ if (!$t.grid || !p.treeGrid) { return; }
199
+ var expanded = p.treeReader.expanded_field, rowid = record[p.localReader.id]; // without prefix
200
+ if (!treeGridFeedback.call($t, "beforeCollapseRow", { rowid: rowid, item: record })) { return; }
201
+ var childern = base.getNodeChildren.call($self, record);
202
+ $(childern).each(function () {
203
+ var id = p.idPrefix + getAccessor(this, p.localReader.id);
204
+ $(base.getGridRowById.call($self, id)).css("display", "none");
205
+ if (this[expanded]) {
206
+ base.collapseRow.call($self, this);
207
+ }
208
+ });
209
+ treeGridFeedback.call($t, "afterCollapseRow", { rowid: rowid, item: record });
210
+ });
211
+ },
212
+ // NS ,adjacency models
213
+ getRootNodes: function () {
214
+ var result = [];
215
+ this.each(function () {
216
+ var $t = this, p = $t.p;
217
+ if (!$t.grid || !p.treeGrid) { return; }
218
+ switch (p.treeGridModel) {
219
+ case "nested":
220
+ var level = p.treeReader.level_field;
221
+ $(p.data).each(function () {
222
+ if (parseInt(this[level], 10) === parseInt(p.tree_root_level, 10)) {
223
+ result.push(this);
224
+ }
225
+ });
226
+ break;
227
+ case "adjacency":
228
+ var parentId = p.treeReader.parent_id_field;
229
+ $(p.data).each(function () {
230
+ if (this[parentId] === null || String(this[parentId]).toLowerCase() === "null") {
231
+ result.push(this);
232
+ }
233
+ });
234
+ break;
235
+ }
236
+ });
237
+ return result;
238
+ },
239
+ getNodeDepth: function (rc) {
240
+ var ret = null;
241
+ this.each(function () {
242
+ var $t = this, p = $t.p;
243
+ if (!$t.grid || !p.treeGrid) { return; }
244
+ switch (p.treeGridModel) {
245
+ case "nested":
246
+ var level = p.treeReader.level_field;
247
+ ret = parseInt(rc[level], 10) - parseInt(p.tree_root_level, 10);
248
+ break;
249
+ case "adjacency":
250
+ ret = base.getNodeAncestors.call($($t), rc).length;
251
+ break;
252
+ }
253
+ });
254
+ return ret;
255
+ },
256
+ getNodeParent: function (rc) {
257
+ // var $t = this instanceof $ && this.length > 0 ? this[0] : this;
258
+ var $t = this[0];
259
+ if (!$t || !$t.grid || $t.p == null || !$t.p.treeGrid || rc == null) { return null; }
260
+ var p = $t.p, treeReader = p.treeReader, parentIdName = treeReader.parent_id_field, parentId = rc[parentIdName];
261
+ if (p.treeGridModel === "nested") {
262
+ var result = null,
263
+ lftc = treeReader.left_field,
264
+ rgtc = treeReader.right_field,
265
+ levelc = treeReader.level_field,
266
+ lft = parseInt(rc[lftc], 10), rgt = parseInt(rc[rgtc], 10), level = parseInt(rc[levelc], 10);
267
+
268
+ $(p.data).each(function () {
269
+ if (parseInt(this[levelc], 10) === level - 1 && parseInt(this[lftc], 10) < lft && parseInt(this[rgtc], 10) > rgt) {
270
+ result = this;
271
+ return false;
272
+ }
273
+ });
274
+ return result;
275
+ }
276
+ if (parentId === null || parentId === "null") { return null; }
277
+ var iParent = p._index[parentId];
278
+ return iParent !== undefined ? p.data[iParent] : null;
279
+ },
280
+ getNodeChildren: function (rc) {
281
+ var result = [];
282
+ this.each(function () {
283
+ var $t = this, p = $t.p;
284
+ if (!$t.grid || !p.treeGrid) { return; }
285
+ switch (p.treeGridModel) {
286
+ case "nested":
287
+ var lftc = p.treeReader.left_field, rgtc = p.treeReader.right_field, levelc = p.treeReader.level_field,
288
+ lft = parseInt(rc[lftc], 10),
289
+ rgt = parseInt(rc[rgtc], 10),
290
+ level = parseInt(rc[levelc], 10);
291
+ $(p.data).each(function () {
292
+ if (parseInt(this[levelc], 10) === level + 1 && parseInt(this[lftc], 10) > lft && parseInt(this[rgtc], 10) < rgt) {
293
+ result.push(this);
294
+ }
295
+ });
296
+ break;
297
+ case "adjacency":
298
+ var parentId = p.treeReader.parent_id_field, dtid = p.localReader.id;
299
+ $(p.data).each(function () {
300
+ if (String(this[parentId]) === String(rc[dtid])) {
301
+ result.push(this);
302
+ }
303
+ });
304
+ break;
305
+ }
306
+ });
307
+ return result;
308
+ },
309
+ getFullTreeNode: function (rc) {
310
+ var result = [];
311
+ this.each(function () {
312
+ var $t = this, p = $t.p, len;
313
+ if (!$t.grid || !p.treeGrid) { return; }
314
+ switch (p.treeGridModel) {
315
+ case "nested":
316
+ var lftc = p.treeReader.left_field, rgtc = p.treeReader.right_field, levelc = p.treeReader.level_field,
317
+ lft = parseInt(rc[lftc], 10),
318
+ rgt = parseInt(rc[rgtc], 10),
319
+ level = parseInt(rc[levelc], 10);
320
+ $(p.data).each(function () {
321
+ if (parseInt(this[levelc], 10) >= level && parseInt(this[lftc], 10) >= lft && parseInt(this[lftc], 10) <= rgt) {
322
+ result.push(this);
323
+ }
324
+ });
325
+ break;
326
+ case "adjacency":
327
+ if (rc) {
328
+ result.push(rc);
329
+ var parentId = p.treeReader.parent_id_field, dtid = p.localReader.id;
330
+ $(p.data).each(function () {
331
+ var i;
332
+ len = result.length;
333
+ for (i = 0; i < len; i++) {
334
+ if (String(result[i][dtid]) === String(this[parentId])) {
335
+ result.push(this);
336
+ break;
337
+ }
338
+ }
339
+ });
340
+ }
341
+ break;
342
+ }
343
+ });
344
+ return result;
345
+ },
346
+ // End NS, adjacency Model
347
+ getNodeAncestors: function (rc) {
348
+ var ancestors = [];
349
+ this.each(function () {
350
+ var $t = this, $self = $($t), getNodeParent = base.getNodeParent;
351
+ if (!$t.grid || !$t.p.treeGrid) { return; }
352
+ var parent = getNodeParent.call($self, rc);
353
+ while (parent) {
354
+ ancestors.push(parent);
355
+ parent = getNodeParent.call($self, parent);
356
+ }
357
+ });
358
+ return ancestors;
359
+ },
360
+ isVisibleNode: function (rc) {
361
+ var result = true;
362
+ this.each(function () {
363
+ var $t = this, p = $t.p;
364
+ if (!$t.grid || !p.treeGrid) { return; }
365
+ var ancestors = base.getNodeAncestors.call($($t), rc), expanded = p.treeReader.expanded_field;
366
+ $(ancestors).each(function () {
367
+ result = result && this[expanded];
368
+ if (!result) { return false; }
369
+ });
370
+ });
371
+ return result;
372
+ },
373
+ isNodeLoaded: function (rc) {
374
+ var result;
375
+ this.each(function () {
376
+ var $t = this, p = $t.p;
377
+ if (!$t.grid || !p.treeGrid) { return; }
378
+ var isLeaf = p.treeReader.leaf_field, loaded = p.treeReader.loaded;
379
+ if (rc !== undefined) {
380
+ if (rc[loaded] !== undefined) {
381
+ result = rc[loaded];
382
+ } else if (rc[isLeaf] || base.getNodeChildren.call($($t), rc).length > 0) {
383
+ result = true;
384
+ } else {
385
+ result = false;
386
+ }
387
+ } else {
388
+ result = false;
389
+ }
390
+ });
391
+ return result;
392
+ },
393
+ expandNode: function (rc) {
394
+ return this.each(function () {
395
+ var $t = this, p = $t.p, id, rc1, icons;
396
+ if (!$t.grid || !p.treeGrid) { return; }
397
+ var treeReader = p.treeReader;
398
+
399
+ if (!rc[treeReader.expanded_field]) {
400
+ id = getAccessor(rc, p.localReader.id);
401
+ if (!treeGridFeedback.call($t, "beforeExpandNode", { rowid: id, item: rc })) { return; }
402
+ rc1 = $("#" + p.idPrefix + jqID(id), $t.grid.bDiv)[0];
403
+
404
+ rc[treeReader.expanded_field] = true;
405
+ icons = getNodeIcons(p, rc);
406
+ $("div.treeclick", rc1).removeClass(icons.collapsed).addClass(icons.common).addClass(icons.expanded);
407
+ if (p.treedatatype !== "local" && !base.isNodeLoaded.call($($t), p.data[p._index[id]]) && !$t.grid.hDiv.loading) {
408
+ // set the value which will be used during processing of the server response
409
+ // in readInput
410
+ p.treeANode = rc1.rowIndex;
411
+ p.datatype = p.treedatatype;
412
+ base.setGridParam.call($($t), {
413
+ postData: p.treeGridModel === "nested" ?
414
+ {
415
+ nodeid: id,
416
+ n_level: rc[treeReader.level_field],
417
+ n_left: rc[treeReader.left_field],
418
+ n_right: rc[treeReader.right_field]
419
+ } :
420
+ {
421
+ nodeid: id,
422
+ n_level: rc[treeReader.level_field],
423
+ parentid: rc[treeReader.parent_id_field]
424
+ }
425
+ });
426
+ $($t).trigger("reloadGrid");
427
+ rc[treeReader.loaded] = true;
428
+ base.setGridParam.call($($t), {
429
+ postData: p.treeGridModel === "nested" ?
430
+ {
431
+ nodeid: "",
432
+ n_level: "",
433
+ n_left: "",
434
+ n_right: ""
435
+ } :
436
+ {
437
+ nodeid: "",
438
+ n_level: "",
439
+ parentid: ""
440
+ }
441
+ });
442
+ }
443
+ treeGridFeedback.call($t, "afterExpandNode", { rowid: id, item: rc });
444
+ }
445
+ });
446
+ },
447
+ collapseNode: function (rc) {
448
+ return this.each(function () {
449
+ var $t = this, p = $t.p, icons;
450
+ if (!$t.grid || !p.treeGrid) { return; }
451
+ var expanded = p.treeReader.expanded_field;
452
+ if (rc[expanded]) {
453
+ var id = getAccessor(rc, p.localReader.id);
454
+ if (!treeGridFeedback.call($t, "beforeCollapseNode", { rowid: id, item: rc })) { return; }
455
+ rc[expanded] = false;
456
+ icons = getNodeIcons(p, rc);
457
+ $("#" + p.idPrefix + jqID(id), $t.grid.bDiv) // $tr
458
+ .find("div.treeclick")
459
+ .removeClass(icons.expanded)
460
+ .addClass(icons.common)
461
+ .addClass(icons.collapsed);
462
+ if (p.unloadNodeOnCollapse === true || ($.jgrid.isFunction(p.unloadNodeOnCollapse) && p.unloadNodeOnCollapse.call($t, rc))) {
463
+ rc[p.treeReader.loaded] = false;
464
+ $($t).jqGrid("delTreeNode", id, true);
465
+ }
466
+ treeGridFeedback.call($t, "afterCollapseNode", { rowid: id, item: rc });
467
+ }
468
+ });
469
+ },
470
+ SortTree: function (sortname, newDir, st, datefmt) {
471
+ return this.each(function () {
472
+ var $t = this, p = $t.p, $self = $($t);
473
+ if (!$t.grid || !p.treeGrid) { return; }
474
+ var i, len, rec, records = [], rt = base.getRootNodes.call($self), query = jgrid.from.call($t, rt);
475
+ // Sorting roots
476
+ query.orderBy(sortname, newDir, st, datefmt);
477
+ var roots = query.select();
478
+
479
+ // Sorting children
480
+ for (i = 0, len = roots.length; i < len; i++) {
481
+ rec = roots[i];
482
+ records.push(rec);
483
+ base.collectChildrenSortTree.call($self, records, rec, sortname, newDir, st, datefmt);
484
+ }
485
+ $.each(records, function (index) {
486
+ var id = getAccessor(this, p.localReader.id);
487
+ $($t.rows[index]).after($self.find(">tbody>tr#" + jqID(id)));
488
+ });
489
+ });
490
+ },
491
+ collectChildrenSortTree: function (records, rec, sortname, newDir, st, datefmt) {
492
+ return this.each(function () {
493
+ var $t = this, $self = $($t);
494
+ if (!$t.grid || !$t.p.treeGrid) { return; }
495
+ var i, len, child, ch = base.getNodeChildren.call($self, rec), query = jgrid.from.call($t, ch);
496
+ query.orderBy(sortname, newDir, st, datefmt);
497
+ var children = query.select();
498
+ for (i = 0, len = children.length; i < len; i++) {
499
+ child = children[i];
500
+ records.push(child);
501
+ base.collectChildrenSortTree.call($self, records, child, sortname, newDir, st, datefmt);
502
+ }
503
+ });
504
+ },
505
+ // experimental
506
+ setTreeRow: function (rowid, data) {
507
+ var success = false;
508
+ this.each(function () {
509
+ var t = this;
510
+ if (!t.grid || !t.p.treeGrid) { return; }
511
+ success = base.setRowData.call($(t), rowid, data);
512
+ });
513
+ return success;
514
+ },
515
+ delTreeNode: function (rowid, skipSelf) {
516
+ return this.each(function () {
517
+ var $t = this, p = $t.p, myright, width, res, key, rid = p.localReader.id, i, $self = $($t),
518
+ left = p.treeReader.left_field,
519
+ right = p.treeReader.right_field;
520
+ if (!$t.grid || !p.treeGrid) { return; }
521
+ var rc = p._index[rowid];
522
+ if (rc !== undefined) {
523
+ // nested
524
+ myright = parseInt(p.data[rc][right], 10);
525
+ width = myright - parseInt(p.data[rc][left], 10) + 1;
526
+ var dr = base.getFullTreeNode.call($self, p.data[rc]);
527
+ if (dr.length > 0) {
528
+ for (i = 0; i < dr.length; i++) {
529
+ if (!skipSelf || rowid !== dr[i][rid]) {
530
+ base.delRowData.call($self, dr[i][rid]);
531
+ }
532
+ }
533
+ }
534
+ if (p.treeGridModel === "nested") {
535
+ // ToDo - update grid data
536
+ res = jgrid.from.call($t, p.data)
537
+ .greater(left, myright, { stype: "integer" })
538
+ .select();
539
+ if (res.length) {
540
+ for (key in res) {
541
+ if (res.hasOwnProperty(key)) {
542
+ res[key][left] = parseInt(res[key][left], 10) - width;
543
+ }
544
+ }
545
+ }
546
+ res = jgrid.from.call($t, p.data)
547
+ .greater(right, myright, { stype: "integer" })
548
+ .select();
549
+ if (res.length) {
550
+ for (key in res) {
551
+ if (res.hasOwnProperty(key)) {
552
+ res[key][right] = parseInt(res[key][right], 10) - width;
553
+ }
554
+ }
555
+ }
556
+ }
557
+ }
558
+ });
559
+ },
560
+ addChildNode: function (nodeid, parentid, data, expandData) {
561
+ return this.each(function () {
562
+ if (!data) { return; }
563
+ var $t = this, p = $t.p, $self = $($t), getInd = base.getInd,
564
+ iconExpanded = p.treeIcons.minus + " tree-minus",
565
+ method, parentindex, parentdata, parentlevel, iRow, rowind = parentid, leaf, maxright,
566
+ expanded = p.treeReader.expanded_field, isLeaf = p.treeReader.leaf_field, level = p.treeReader.level_field,
567
+ parent = p.treeReader.parent_id_field,
568
+ left = p.treeReader.left_field,
569
+ right = p.treeReader.right_field,
570
+ loaded = p.treeReader.loaded;
571
+ if (expandData === undefined) { expandData = false; }
572
+ if (nodeid == null) {
573
+ nodeid = jgrid.randId();
574
+ }
575
+ var prow = getInd.call($self, parentid);
576
+ leaf = false;
577
+ // if not a parent we assume root
578
+ if (parentid === undefined || parentid === null || parentid === "") {
579
+ parentid = null;
580
+ rowind = null;
581
+ method = "last";
582
+ parentlevel = p.tree_root_level;
583
+ } else {
584
+ method = "after";
585
+ parentindex = p._index[parentid];
586
+ parentdata = p.data[parentindex];
587
+ parentid = parentdata[p.localReader.id];
588
+ iRow = getInd.call($self, parentid);
589
+ parentlevel = parseInt(parentdata[level], 10) + 1;
590
+ var childs = base.getFullTreeNode.call($self, parentdata);
591
+ // if there are child nodes get the last index of it
592
+ if (childs.length) {
593
+ // find the max rowIndex of the children
594
+ var iChild, iChildRow, childId;
595
+ for (iChild = 0; iChild < childs.length; iChild++) {
596
+ childId = childs[iChild][p.localReader.id];
597
+ iChildRow = getInd.call($self, childId);
598
+ if (iChildRow > iRow) {
599
+ iRow = iChildRow;
600
+ rowind = childId;
601
+ }
602
+ }
603
+ }
604
+ // if the node is leaf
605
+ if (parentdata[isLeaf]) {
606
+ leaf = true;
607
+ parentdata[expanded] = true;
608
+ //var prow = getInd.call($self, parentid);
609
+ $($t.rows[prow])
610
+ .find("span.cell-wrapperleaf").removeClass("cell-wrapperleaf").addClass("cell-wrapper")
611
+ .end()
612
+ .find("div.tree-leaf").removeClass(p.treeIcons.leaf + " tree-leaf").addClass(p.treeIcons.commonIconClass).addClass(iconExpanded);
613
+ p.data[parentindex][isLeaf] = false;
614
+ parentdata[loaded] = true;
615
+ }
616
+ }
617
+
618
+ if (data[expanded] === undefined) { data[expanded] = false; }
619
+ if (data[loaded] === undefined) { data[loaded] = false; }
620
+ data[level] = parentlevel;
621
+ if (data[isLeaf] === undefined) { data[isLeaf] = true; }
622
+ if (p.treeGridModel === "adjacency") {
623
+ data[parent] = parentid;
624
+ }
625
+ if (p.treeGridModel === "nested") {
626
+ // this method requiere more attention
627
+ var query, res, key;
628
+ //maxright = parseInt(maxright,10);
629
+ // ToDo - update grid data
630
+ if (parentid !== null) {
631
+ maxright = parseInt(parentdata[right], 10);
632
+ query = jgrid.from.call($t, p.data);
633
+ query = query.greaterOrEquals(right, maxright, { stype: "integer" });
634
+ res = query.select();
635
+ if (res.length) {
636
+ for (key in res) {
637
+ if (res.hasOwnProperty(key)) {
638
+ res[key][left] = res[key][left] > maxright ? parseInt(res[key][left], 10) + 2 : res[key][left];
639
+ res[key][right] = res[key][right] >= maxright ? parseInt(res[key][right], 10) + 2 : res[key][right];
640
+ }
641
+ }
642
+ }
643
+ data[left] = maxright;
644
+ data[right] = maxright + 1;
645
+ } else {
646
+ maxright = parseInt(base.getCol.call($self, right, false, "max"), 10);
647
+ res = jgrid.from.call($t, p.data)
648
+ .greater(left, maxright, { stype: "integer" })
649
+ .select();
650
+ if (res.length) {
651
+ for (key in res) {
652
+ if (res.hasOwnProperty(key)) {
653
+ res[key][left] = parseInt(res[key][left], 10) + 2;
654
+ }
655
+ }
656
+ }
657
+ res = jgrid.from.call($t, p.data)
658
+ .greater(right, maxright, { stype: "integer" })
659
+ .select();
660
+ if (res.length) {
661
+ for (key in res) {
662
+ if (res.hasOwnProperty(key)) {
663
+ res[key][right] = parseInt(res[key][right], 10) + 2;
664
+ }
665
+ }
666
+ }
667
+ data[left] = maxright + 1;
668
+ data[right] = maxright + 2;
669
+ }
670
+ }
671
+ if (parentid === null || base.isNodeLoaded.call($self, parentdata) || leaf) {
672
+ base.addRowData.call($self, nodeid, data, method, rowind);
673
+ }
674
+ if (parentdata && !parentdata[expanded] && expandData) {
675
+ $($t.rows[prow])
676
+ .find("div.treeclick")
677
+ .click();
678
+ }
679
+ });
680
+ }
681
+ });
682
+ // end module grid.treegrid
683
+ }));