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.
- package/.tscache/all/hashes/free-jqgrid.d.ts-74303c8b076937117540c0cb798f2053 +1 -0
- package/.tscache/all/hashes/test.ts-0d81877a31bc5d7ac52dd35a66602f01 +1 -0
- package/.tscache/all/timestamp +0 -0
- package/dist/css/ui.jqgrid.css +1618 -0
- package/dist/css/ui.jqgrid.min.css +4 -0
- package/dist/css/ui.jqgrid.min.css.map +1 -0
- package/dist/i18n/grid.locale-ar.js +198 -0
- package/dist/i18n/grid.locale-bg.js +201 -0
- package/dist/i18n/grid.locale-bs.js +230 -0
- package/dist/i18n/grid.locale-ca.js +204 -0
- package/dist/i18n/grid.locale-cn.js +237 -0
- package/dist/i18n/grid.locale-cs.js +197 -0
- package/dist/i18n/grid.locale-da.js +196 -0
- package/dist/i18n/grid.locale-de.js +240 -0
- package/dist/i18n/grid.locale-el.js +195 -0
- package/dist/i18n/grid.locale-en.js +256 -0
- package/dist/i18n/grid.locale-es.js +202 -0
- package/dist/i18n/grid.locale-fa.js +211 -0
- package/dist/i18n/grid.locale-fi.js +201 -0
- package/dist/i18n/grid.locale-fr.js +197 -0
- package/dist/i18n/grid.locale-gl.js +197 -0
- package/dist/i18n/grid.locale-he.js +198 -0
- package/dist/i18n/grid.locale-hr.js +231 -0
- package/dist/i18n/grid.locale-hu.js +196 -0
- package/dist/i18n/grid.locale-id.js +238 -0
- package/dist/i18n/grid.locale-is.js +197 -0
- package/dist/i18n/grid.locale-it.js +189 -0
- package/dist/i18n/grid.locale-ja.js +203 -0
- package/dist/i18n/grid.locale-kr.js +194 -0
- package/dist/i18n/grid.locale-lt.js +199 -0
- package/dist/i18n/grid.locale-me.js +198 -0
- package/dist/i18n/grid.locale-nl.js +208 -0
- package/dist/i18n/grid.locale-no.js +180 -0
- package/dist/i18n/grid.locale-pl.js +204 -0
- package/dist/i18n/grid.locale-pt-br.js +210 -0
- package/dist/i18n/grid.locale-pt.js +196 -0
- package/dist/i18n/grid.locale-ro.js +210 -0
- package/dist/i18n/grid.locale-ru.js +196 -0
- package/dist/i18n/grid.locale-sk.js +198 -0
- package/dist/i18n/grid.locale-sl.js +230 -0
- package/dist/i18n/grid.locale-sr.js +199 -0
- package/dist/i18n/grid.locale-sv.js +198 -0
- package/dist/i18n/grid.locale-th.js +195 -0
- package/dist/i18n/grid.locale-tr.js +197 -0
- package/dist/i18n/grid.locale-tw.js +199 -0
- package/dist/i18n/grid.locale-ua.js +199 -0
- package/dist/i18n/grid.locale-vi.js +238 -0
- package/dist/i18n/min/grid.locale-ar.js +10 -0
- package/dist/i18n/min/grid.locale-ar.js.map +1 -0
- package/dist/i18n/min/grid.locale-bg.js +10 -0
- package/dist/i18n/min/grid.locale-bg.js.map +1 -0
- package/dist/i18n/min/grid.locale-ca.js +15 -0
- package/dist/i18n/min/grid.locale-ca.js.map +1 -0
- package/dist/i18n/min/grid.locale-cn.js +10 -0
- package/dist/i18n/min/grid.locale-cn.js.map +1 -0
- package/dist/i18n/min/grid.locale-cs.js +11 -0
- package/dist/i18n/min/grid.locale-cs.js.map +1 -0
- package/dist/i18n/min/grid.locale-da.js +10 -0
- package/dist/i18n/min/grid.locale-da.js.map +1 -0
- package/dist/i18n/min/grid.locale-de.js +21 -0
- package/dist/i18n/min/grid.locale-de.js.map +1 -0
- package/dist/i18n/min/grid.locale-el.js +10 -0
- package/dist/i18n/min/grid.locale-el.js.map +1 -0
- package/dist/i18n/min/grid.locale-en.js +11 -0
- package/dist/i18n/min/grid.locale-en.js.map +1 -0
- package/dist/i18n/min/grid.locale-es.js +16 -0
- package/dist/i18n/min/grid.locale-es.js.map +1 -0
- package/dist/i18n/min/grid.locale-fa.js +8 -0
- package/dist/i18n/min/grid.locale-fa.js.map +1 -0
- package/dist/i18n/min/grid.locale-fi.js +11 -0
- package/dist/i18n/min/grid.locale-fi.js.map +1 -0
- package/dist/i18n/min/grid.locale-fr.js +10 -0
- package/dist/i18n/min/grid.locale-fr.js.map +1 -0
- package/dist/i18n/min/grid.locale-gl.js +9 -0
- package/dist/i18n/min/grid.locale-gl.js.map +1 -0
- package/dist/i18n/min/grid.locale-he.js +10 -0
- package/dist/i18n/min/grid.locale-he.js.map +1 -0
- package/dist/i18n/min/grid.locale-hr.js +11 -0
- package/dist/i18n/min/grid.locale-hr.js.map +1 -0
- package/dist/i18n/min/grid.locale-hu.js +10 -0
- package/dist/i18n/min/grid.locale-hu.js.map +1 -0
- package/dist/i18n/min/grid.locale-id.js +10 -0
- package/dist/i18n/min/grid.locale-id.js.map +1 -0
- package/dist/i18n/min/grid.locale-is.js +9 -0
- package/dist/i18n/min/grid.locale-is.js.map +1 -0
- package/dist/i18n/min/grid.locale-it.js +2 -0
- package/dist/i18n/min/grid.locale-it.js.map +1 -0
- package/dist/i18n/min/grid.locale-ja.js +10 -0
- package/dist/i18n/min/grid.locale-ja.js.map +1 -0
- package/dist/i18n/min/grid.locale-kr.js +2 -0
- package/dist/i18n/min/grid.locale-kr.js.map +1 -0
- package/dist/i18n/min/grid.locale-lt.js +10 -0
- package/dist/i18n/min/grid.locale-lt.js.map +1 -0
- package/dist/i18n/min/grid.locale-me.js +10 -0
- package/dist/i18n/min/grid.locale-me.js.map +1 -0
- package/dist/i18n/min/grid.locale-nl.js +2 -0
- package/dist/i18n/min/grid.locale-nl.js.map +1 -0
- package/dist/i18n/min/grid.locale-no.js +2 -0
- package/dist/i18n/min/grid.locale-no.js.map +1 -0
- package/dist/i18n/min/grid.locale-pl.js +18 -0
- package/dist/i18n/min/grid.locale-pl.js.map +1 -0
- package/dist/i18n/min/grid.locale-pt-br.js +21 -0
- package/dist/i18n/min/grid.locale-pt-br.js.map +1 -0
- package/dist/i18n/min/grid.locale-pt.js +9 -0
- package/dist/i18n/min/grid.locale-pt.js.map +1 -0
- package/dist/i18n/min/grid.locale-ro.js +10 -0
- package/dist/i18n/min/grid.locale-ro.js.map +1 -0
- package/dist/i18n/min/grid.locale-ru.js +10 -0
- package/dist/i18n/min/grid.locale-ru.js.map +1 -0
- package/dist/i18n/min/grid.locale-sk.js +10 -0
- package/dist/i18n/min/grid.locale-sk.js.map +1 -0
- package/dist/i18n/min/grid.locale-sr.js +10 -0
- package/dist/i18n/min/grid.locale-sr.js.map +1 -0
- package/dist/i18n/min/grid.locale-sv.js +10 -0
- package/dist/i18n/min/grid.locale-sv.js.map +1 -0
- package/dist/i18n/min/grid.locale-th.js +10 -0
- package/dist/i18n/min/grid.locale-th.js.map +1 -0
- package/dist/i18n/min/grid.locale-tr.js +10 -0
- package/dist/i18n/min/grid.locale-tr.js.map +1 -0
- package/dist/i18n/min/grid.locale-tw.js +11 -0
- package/dist/i18n/min/grid.locale-tw.js.map +1 -0
- package/dist/i18n/min/grid.locale-ua.js +10 -0
- package/dist/i18n/min/grid.locale-ua.js.map +1 -0
- package/dist/i18n/min/grid.locale-vi.js +10 -0
- package/dist/i18n/min/grid.locale-vi.js.map +1 -0
- package/dist/jquery.jqgrid.min.js +11 -0
- package/dist/jquery.jqgrid.min.js.map +1 -0
- package/{js/jquery.jqgrid.src.js.1 → dist/jquery.jqgrid.src.js} +1 -1
- package/dist/modules/grid.base.js +8518 -0
- package/dist/modules/grid.celledit.js +673 -0
- package/dist/modules/grid.common.js +844 -0
- package/dist/modules/grid.custom.js +1795 -0
- package/dist/modules/grid.filter.js +897 -0
- package/dist/modules/grid.formedit.js +2537 -0
- package/dist/modules/grid.grouping.js +737 -0
- package/dist/modules/grid.import.js +251 -0
- package/dist/modules/grid.inlinedit.js +784 -0
- package/dist/modules/grid.jqueryui.js +965 -0
- package/dist/modules/grid.pivot.js +862 -0
- package/dist/modules/grid.subgrid.js +379 -0
- package/dist/modules/grid.tbltogrid.js +141 -0
- package/dist/modules/grid.treegrid.js +683 -0
- package/dist/modules/jqdnr.js +188 -0
- package/dist/modules/jqmodal.js +292 -0
- package/dist/modules/jquery.fmatter.js +1061 -0
- package/dist/modules/jsonxml.js +343 -0
- package/dist/modules/min/grid.base.js +11 -0
- package/dist/modules/min/grid.base.js.map +1 -0
- package/dist/modules/min/grid.celledit.js +2 -0
- package/dist/modules/min/grid.celledit.js.map +1 -0
- package/dist/modules/min/grid.common.js +2 -0
- package/dist/modules/min/grid.common.js.map +1 -0
- package/dist/modules/min/grid.custom.js +2 -0
- package/dist/modules/min/grid.custom.js.map +1 -0
- package/dist/modules/min/grid.filter.js +2 -0
- package/dist/modules/min/grid.filter.js.map +1 -0
- package/dist/modules/min/grid.formedit.js +2 -0
- package/dist/modules/min/grid.formedit.js.map +1 -0
- package/dist/modules/min/grid.grouping.js +2 -0
- package/dist/modules/min/grid.grouping.js.map +1 -0
- package/dist/modules/min/grid.import.js +2 -0
- package/dist/modules/min/grid.import.js.map +1 -0
- package/dist/modules/min/grid.inlinedit.js +2 -0
- package/dist/modules/min/grid.inlinedit.js.map +1 -0
- package/dist/modules/min/grid.jqueryui.js +2 -0
- package/dist/modules/min/grid.jqueryui.js.map +1 -0
- package/dist/modules/min/grid.pivot.js +2 -0
- package/dist/modules/min/grid.pivot.js.map +1 -0
- package/dist/modules/min/grid.subgrid.js +2 -0
- package/dist/modules/min/grid.subgrid.js.map +1 -0
- package/dist/modules/min/grid.tbltogrid.js +2 -0
- package/dist/modules/min/grid.tbltogrid.js.map +1 -0
- package/dist/modules/min/grid.treegrid.js +2 -0
- package/dist/modules/min/grid.treegrid.js.map +1 -0
- package/dist/modules/min/jqdnr.js +2 -0
- package/dist/modules/min/jqdnr.js.map +1 -0
- package/dist/modules/min/jqmodal.js +2 -0
- package/dist/modules/min/jqmodal.js.map +1 -0
- package/dist/modules/min/jquery.fmatter.js +2 -0
- package/dist/modules/min/jquery.fmatter.js.map +1 -0
- package/dist/modules/min/jsonxml.js +2 -0
- package/dist/modules/min/jsonxml.js.map +1 -0
- package/dist/plugins/css/ui.multiselect.css +30 -0
- package/dist/plugins/css/ui.multiselect.min.css +2 -0
- package/dist/plugins/css/ui.multiselect.min.css.map +1 -0
- package/dist/plugins/grid.odata.js +1313 -0
- package/dist/plugins/jqgrid_download.js +109 -0
- package/dist/plugins/jquery.contextmenu-ui.js +304 -0
- package/dist/plugins/jquery.contextmenu.js +174 -0
- package/dist/plugins/jquery.createcontexmenufromnavigatorbuttons.js +172 -0
- package/dist/plugins/jquery.jqgrid.showhidecolumnmenu.js +201 -0
- package/dist/plugins/min/grid.odata.js +11 -0
- package/dist/plugins/min/grid.odata.js.map +1 -0
- package/dist/plugins/min/jquery.contextmenu-ui.js +26 -0
- package/dist/plugins/min/jquery.contextmenu-ui.js.map +1 -0
- package/dist/plugins/min/jquery.contextmenu.js +19 -0
- package/dist/plugins/min/jquery.contextmenu.js.map +1 -0
- package/dist/plugins/min/jquery.createcontexmenufromnavigatorbuttons.js +12 -0
- package/dist/plugins/min/jquery.createcontexmenufromnavigatorbuttons.js.map +1 -0
- package/dist/plugins/min/jquery.jqgrid.showhidecolumnmenu.js +10 -0
- package/dist/plugins/min/jquery.jqgrid.showhidecolumnmenu.js.map +1 -0
- package/dist/plugins/min/ui.multiselect.js +30 -0
- package/dist/plugins/min/ui.multiselect.js.map +1 -0
- package/dist/plugins/ui.multiselect.js +389 -0
- package/dist/ts/free-jqgrid.d.ts +2132 -0
- package/js/jquery.jqgrid.min.js +1 -1
- package/js/jquery.jqgrid.min.js.map +1 -1
- package/js/jquery.jqgrid.src.js +8 -3
- package/libre-jqgrid-4.17.4.tgz +0 -0
- package/package.json +1 -1
- package/.github/workflows/npm.yml +0 -47
|
@@ -0,0 +1,965 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jqGrid addons using jQuery UI
|
|
3
|
+
* Author: Mark Williams
|
|
4
|
+
* Changed by Oleg Kiriljuk, oleg.kiriljuk@ok-soft-gmbh.com
|
|
5
|
+
* Maintained by 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
|
+
* depends on jQuery UI
|
|
10
|
+
**/
|
|
11
|
+
|
|
12
|
+
/*jshint evil:true, eqeqeq:false, eqnull:true, devel:true */
|
|
13
|
+
/*global jQuery, define, exports, module, require */
|
|
14
|
+
/*jslint browser: true, devel: true, eqeq: true, nomen: true, plusplus: true, unparam: true, vars: true, white: true */
|
|
15
|
+
(function (global, factory) {
|
|
16
|
+
"use strict";
|
|
17
|
+
if (typeof define === "function" && define.amd) {
|
|
18
|
+
// AMD. Register as an anonymous module.
|
|
19
|
+
define([
|
|
20
|
+
"jquery",
|
|
21
|
+
"./grid.base",
|
|
22
|
+
//"../plugins/ui.multiselect",
|
|
23
|
+
"free-jqgrid-plugins/ui.multiselect",
|
|
24
|
+
"jquery-ui/dialog",
|
|
25
|
+
"jquery-ui/draggable",
|
|
26
|
+
"jquery-ui/droppable",
|
|
27
|
+
"jquery-ui/resizable",
|
|
28
|
+
"jquery-ui/sortable"
|
|
29
|
+
], function ($) {
|
|
30
|
+
return factory($, global, global.document);
|
|
31
|
+
});
|
|
32
|
+
} else if (typeof module === "object" && module.exports) {
|
|
33
|
+
// Node/CommonJS
|
|
34
|
+
module.exports = function (root, $) {
|
|
35
|
+
if (!root) {
|
|
36
|
+
root = window;
|
|
37
|
+
}
|
|
38
|
+
if ($ === undefined) {
|
|
39
|
+
// require("jquery") returns a factory that requires window to
|
|
40
|
+
// build a jQuery instance, we normalize how we use modules
|
|
41
|
+
// that require this pattern but the window provided is a noop
|
|
42
|
+
// if it's defined (how jquery works)
|
|
43
|
+
$ = typeof window !== "undefined" ?
|
|
44
|
+
require("jquery") :
|
|
45
|
+
require("jquery")(root);
|
|
46
|
+
}
|
|
47
|
+
require("./grid.base");
|
|
48
|
+
//require("../plugins/ui.multiselect");
|
|
49
|
+
require("free-jqgrid-plugins/ui.multiselect");
|
|
50
|
+
require("jquery-ui/dialog");
|
|
51
|
+
require("jquery-ui/draggable");
|
|
52
|
+
require("jquery-ui/droppable");
|
|
53
|
+
require("jquery-ui/resizable");
|
|
54
|
+
require("jquery-ui/sortable");
|
|
55
|
+
factory($, root, root.document);
|
|
56
|
+
return $;
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
// Browser globals
|
|
60
|
+
factory(jQuery, global, global.document);
|
|
61
|
+
}
|
|
62
|
+
}(typeof window !== "undefined" ? window : this, function ($, window, document) {
|
|
63
|
+
"use strict";
|
|
64
|
+
var jgrid = $.jgrid, jqID = jgrid.jqID;
|
|
65
|
+
// begin module grid.jqueryui
|
|
66
|
+
var $UiMultiselect = $.ui != null ? $.ui.multiselect : null,
|
|
67
|
+
reorderSelectedColumns = function (iColItem) {
|
|
68
|
+
/* Background information:
|
|
69
|
+
*
|
|
70
|
+
* Multiselect contains the list of selected items this.selectedList,
|
|
71
|
+
* which is jQuery wrapper of <ul> element. The items of this.selectedList
|
|
72
|
+
* are <li> elements, which represent visible (hidden:false) and movable
|
|
73
|
+
* (hidedlg:false) columns of the grid.
|
|
74
|
+
*
|
|
75
|
+
* Additionally there are exist hidden <select multiple="multiple">.
|
|
76
|
+
* Every <option> of the <select> corresponds the column of the grid.
|
|
77
|
+
* The visible columns (hidden:false) are selected. The value of the <option>
|
|
78
|
+
* contains the column index (iCol) in colModel. <li> elements of
|
|
79
|
+
* this.selectedLis have data with the "optionLink" pointed to the corresponding
|
|
80
|
+
* option of the hidden select.
|
|
81
|
+
*
|
|
82
|
+
* this.grid is the DOM of the grid and this.newColOrder is the array with
|
|
83
|
+
* ALL column names in the order, which should be applied after reordering
|
|
84
|
+
* the grid. Additionally this.gh contains the COPY of p.groupHeader.groupHeaders.
|
|
85
|
+
* It's important that startColumnName property of elements of
|
|
86
|
+
* p.groupHeader.groupHeaders could be changed during reordering of the columns.
|
|
87
|
+
* On the other side the user can't click Cancel button of columnChooser for
|
|
88
|
+
* breaking reordering. Because of that this.gh contains the COPY of
|
|
89
|
+
* p.groupHeader.groupHeaders and the original p.groupHeader.groupHeaders will be
|
|
90
|
+
* not changed in the reorderSelectedColumns function.
|
|
91
|
+
*
|
|
92
|
+
* An important implementation problem: reorderSelectedColumns function will be
|
|
93
|
+
* called after ONE reordering of the columns. On the other side, the user can
|
|
94
|
+
* reorder the columns MULTIPLE TIMES before saving the new order. Thus, one
|
|
95
|
+
* have to take in consideration not only the original order of columns in
|
|
96
|
+
* colModel, but THE CURRENT order of the columns saved only internally in
|
|
97
|
+
* the dialog in this.newColOrder.
|
|
98
|
+
*/
|
|
99
|
+
if (this.grid != null && this.grid.p != null) {
|
|
100
|
+
var that = this, p = this.grid.p, iCol, j, iGrp, ghItem,
|
|
101
|
+
gh = this.gh, selectedList = this.selectedList, inGroup = this.inGroup,
|
|
102
|
+
items = selectedList.find("li"), optionLink,
|
|
103
|
+
indexOfAddedItem = items.length - 1,
|
|
104
|
+
enumSelected = function (callback, startIndex, reverse) {
|
|
105
|
+
var i, opt, items = selectedList.find("li");
|
|
106
|
+
if (startIndex === undefined) {
|
|
107
|
+
startIndex = reverse ? items.length - 1 : 0;
|
|
108
|
+
}
|
|
109
|
+
for (i = startIndex; !reverse ? i < items.length : i >= 0; !reverse ? i++ : i--) {
|
|
110
|
+
opt = $(items[i]).data("optionLink");
|
|
111
|
+
if (opt && callback.call(items[i], parseInt(opt.val(), 10), i)) {
|
|
112
|
+
return i;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
updateNewColOrder = function () {
|
|
117
|
+
// !!! the function set additionally indexOfAddedItem and update items
|
|
118
|
+
|
|
119
|
+
// remove iColItem from this.newColOrder
|
|
120
|
+
j = $.inArray(p.colModel[iColItem].name, that.newColOrder);
|
|
121
|
+
if (j >= 0) {
|
|
122
|
+
that.newColOrder.splice(j, 1);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// refill items
|
|
126
|
+
items = selectedList.find("li");
|
|
127
|
+
|
|
128
|
+
// iCol will be the index in newColOrder. The order of columns in items
|
|
129
|
+
// should be mostly THE SAME like in selectedList, but newColOrder
|
|
130
|
+
// contains additional elements (hidden and hidedlg). The array items
|
|
131
|
+
// on the other side contains just inserted iColItem element.
|
|
132
|
+
|
|
133
|
+
// we need find indexOfAddedItem - the index of <li> with iColItem
|
|
134
|
+
// in the list of this.selectedList.find("li") elements
|
|
135
|
+
iCol = 0;
|
|
136
|
+
enumSelected(
|
|
137
|
+
function (iColOld, index) {
|
|
138
|
+
if (iColOld === iColItem) {
|
|
139
|
+
indexOfAddedItem = index;
|
|
140
|
+
// if iColItem is in the same header group as p.colModel[iCol] or
|
|
141
|
+
// both belongs no header group then the column could be NOT in
|
|
142
|
+
// selectedList. I find better to insert the item AFTER the hidden
|
|
143
|
+
// or non-movable columns (like "rn", "subgrid" column or other)
|
|
144
|
+
while (iCol >= 0 && iCol < p.colModel.length && iCol !== iColItem &&
|
|
145
|
+
(p.colModel[iCol].hidden || p.colModel[iCol].hidedlg) &&
|
|
146
|
+
(inGroup == null ||
|
|
147
|
+
//inGroup[iCol] !== undefined && inGroup[iColItem] !== undefined &&
|
|
148
|
+
inGroup[iCol] === inGroup[iColItem])) {
|
|
149
|
+
iCol++;
|
|
150
|
+
}
|
|
151
|
+
that.newColOrder.splice(iCol, 0, p.colModel[iColItem].name);
|
|
152
|
+
return true; // stop enumeration
|
|
153
|
+
}
|
|
154
|
+
// selectedList contains SUBSET of columns from colModel, but newColOrder
|
|
155
|
+
// contains ALL columns. It's important that all columns from selectedList
|
|
156
|
+
// exist in newColOrder IN THE SAME order. Thus iCol will be the current
|
|
157
|
+
// index in newColOrder array with p.colModel[iColOld].name column name.
|
|
158
|
+
iCol = $.inArray(p.colModel[iColOld].name, that.newColOrder, iCol);
|
|
159
|
+
if (iCol < 0) {
|
|
160
|
+
// to be sure that the code works in case of some errors too
|
|
161
|
+
iCol = $.inArray(p.colModel[iColOld].name, that.newColOrder);
|
|
162
|
+
}
|
|
163
|
+
iCol++;
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
},
|
|
167
|
+
enumPreviousAndInsertAfter = function (iCol) {
|
|
168
|
+
if (inGroup[iCol] === inGroup[iColItem]) {
|
|
169
|
+
$(this).after(items[indexOfAddedItem]);
|
|
170
|
+
updateNewColOrder();
|
|
171
|
+
return true; // stop enumeration
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
enumNextAndInsertBefore = function (iCol) {
|
|
175
|
+
if (inGroup[iCol] === inGroup[iColItem]) {
|
|
176
|
+
$(this).before(items[indexOfAddedItem]);
|
|
177
|
+
updateNewColOrder();
|
|
178
|
+
return true; // stop enumeration
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
updateStartColumn = function (iCol) {
|
|
182
|
+
if (inGroup[iCol] === inGroup[iColItem] && inGroup[iCol] !== undefined) {
|
|
183
|
+
gh[inGroup[iCol]].startColumnName = p.colModel[iCol].name;
|
|
184
|
+
return true; // stop enumeration
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Fix potition of added/moved item iColItem in that.newColOrder array.
|
|
189
|
+
// We syncronize only the initial state of newColOrder. The position of
|
|
190
|
+
// iColItem item can be changed later in both selectedList and newColOrder
|
|
191
|
+
updateNewColOrder();
|
|
192
|
+
|
|
193
|
+
if (gh && gh[inGroup[iColItem]] !== undefined) {
|
|
194
|
+
// the item belong to some group
|
|
195
|
+
ghItem = gh[inGroup[iColItem]];
|
|
196
|
+
for (j = 0; j < ghItem.numberOfColumns; j++) {
|
|
197
|
+
iCol = p.iColByName[ghItem.startColumnName] + j;
|
|
198
|
+
if (!p.colModel[iCol].hidden && !p.colModel[iCol].hidedlg) {
|
|
199
|
+
// the columns are displayed in the selectedList
|
|
200
|
+
|
|
201
|
+
// We need to enumerate items in reverse order and to find the index of the item
|
|
202
|
+
// in the array items comparing the items by $(items[j]).data("optionLink").val()
|
|
203
|
+
// If the item is found then append prevously found item AFTER this one.
|
|
204
|
+
// We can use j variable bacause the outer loop will be exit (see break below)
|
|
205
|
+
enumSelected(
|
|
206
|
+
enumPreviousAndInsertAfter,
|
|
207
|
+
indexOfAddedItem - 1,
|
|
208
|
+
true // enum in reverse order
|
|
209
|
+
);
|
|
210
|
+
// If step 2 didn't find the group then we need examin NEXT items and find
|
|
211
|
+
// the items from the same group. We should test the items in sequential order
|
|
212
|
+
// after the item found. If the item is found then apend prevously found
|
|
213
|
+
// item BEFORE this one.
|
|
214
|
+
enumSelected(
|
|
215
|
+
enumNextAndInsertBefore,
|
|
216
|
+
indexOfAddedItem + 1
|
|
217
|
+
);
|
|
218
|
+
// fix the name of the first column in the group
|
|
219
|
+
enumSelected(updateStartColumn);
|
|
220
|
+
break; // !!!
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
} else if (gh) {
|
|
224
|
+
// The item from no group is added/moved.
|
|
225
|
+
// We have to verify that the item is not dropped inside of some header group
|
|
226
|
+
// find the index of added/moved element in this.selectedList.find("li")
|
|
227
|
+
items = selectedList.find("li");
|
|
228
|
+
j = enumSelected(function (iCol) {
|
|
229
|
+
if (iCol === iColItem) {
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
if (j + 1 >= items.length || j < 0) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
optionLink = $(items[j + 1]).data("optionLink");
|
|
237
|
+
if (optionLink) {
|
|
238
|
+
iGrp = inGroup[parseInt(optionLink.val(), 10)];
|
|
239
|
+
if (iGrp !== undefined) {
|
|
240
|
+
optionLink = $(items[j - 1]).data("optionLink");
|
|
241
|
+
if (optionLink && inGroup[parseInt(optionLink.val(), 10)] === iGrp) {
|
|
242
|
+
// The next and the previous items are in the same group, but
|
|
243
|
+
// the added/moved item in NOT in the group.
|
|
244
|
+
// We have to move the item items[j] AFTER the last item of the group.
|
|
245
|
+
var iColNotInTheGroup = enumSelected(
|
|
246
|
+
function (iCol) {
|
|
247
|
+
if (inGroup[iCol] !== iGrp) {
|
|
248
|
+
return true; // stop enumeration
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
j + 1 // start enumeration with the index
|
|
252
|
+
);
|
|
253
|
+
$(items[iColNotInTheGroup === undefined || iColNotInTheGroup >= items.length ? items.length - 1 : iColNotInTheGroup - 1])
|
|
254
|
+
.after(items[indexOfAddedItem]);
|
|
255
|
+
updateNewColOrder();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
if (jgrid.msie && jgrid.msiever() === 8) {
|
|
263
|
+
$.expr[":"].hidden = function (elem) {
|
|
264
|
+
return elem.offsetWidth === 0 || elem.offsetHeight === 0 ||
|
|
265
|
+
elem.style.display === "none";
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
// requiere load multiselect before grid
|
|
269
|
+
jgrid._multiselect = false;
|
|
270
|
+
if ($UiMultiselect) {
|
|
271
|
+
if ($UiMultiselect.prototype._setSelected) {
|
|
272
|
+
var setSelected = $UiMultiselect.prototype._setSelected;
|
|
273
|
+
$UiMultiselect.prototype._setSelected = function (item, selected) {
|
|
274
|
+
// the method will be called if the user clicks "+" button on the item of "available" list
|
|
275
|
+
// or if the user clicks "-" button on the item of "selected" list.
|
|
276
|
+
// The parameter "selected" is equal true on click on the item of "selected" list
|
|
277
|
+
// and false on click on the item of "available" list.
|
|
278
|
+
var ret = setSelected.call(this, item, selected), elt = this.element,
|
|
279
|
+
iColItem = parseInt(item.data("optionLink").val(), 10);
|
|
280
|
+
if (selected && this.selectedList) {
|
|
281
|
+
// reorder items of selectedList
|
|
282
|
+
// all items of selectedList from one group have to be together
|
|
283
|
+
// all items of availableList from one group have to be together
|
|
284
|
+
reorderSelectedColumns.call(this, iColItem);
|
|
285
|
+
|
|
286
|
+
// apply the new sort order to the original selectbox
|
|
287
|
+
this.selectedList.find("li").each(function () {
|
|
288
|
+
if ($(this).data("optionLink")) {
|
|
289
|
+
$(this).data("optionLink").remove().appendTo(elt);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return ret;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
if ($UiMultiselect.prototype.destroy) {
|
|
297
|
+
$UiMultiselect.prototype.destroy = function () {
|
|
298
|
+
var self = this;
|
|
299
|
+
self.element.show();
|
|
300
|
+
self.container.remove();
|
|
301
|
+
if ($.Widget === undefined) {
|
|
302
|
+
$.widget.prototype.destroy.apply(self, arguments);
|
|
303
|
+
} else {
|
|
304
|
+
$.Widget.prototype.destroy.apply(self, arguments);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
jgrid._multiselect = true;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
jgrid.extend({
|
|
312
|
+
sortableColumns: function (tblrow) {
|
|
313
|
+
return this.each(function () {
|
|
314
|
+
var ts = this, p = ts.p, tid = jqID(p.id);
|
|
315
|
+
if (!p || !p.sortable || !$.jgrid.isFunction($.fn.sortable)) { return; }
|
|
316
|
+
function start() { p.disableClick = true; }
|
|
317
|
+
var sortableOpts = {
|
|
318
|
+
tolerance: "pointer",
|
|
319
|
+
axis: "x",
|
|
320
|
+
scrollSensitivity: "1",
|
|
321
|
+
items: ">th:not(:has(#jqgh_" + tid + "_cb" + ",#jqgh_" + tid + "_rn" + ",#jqgh_" + tid + "_subgrid),:hidden)",
|
|
322
|
+
placeholder: {
|
|
323
|
+
element: function (item) {
|
|
324
|
+
var el = $(document.createElement(item[0].nodeName))
|
|
325
|
+
.addClass(item[0].className + " ui-sortable-placeholder ui-state-highlight")
|
|
326
|
+
.removeClass("ui-sortable-helper")[0];
|
|
327
|
+
return el;
|
|
328
|
+
},
|
|
329
|
+
update: function (self, o) {
|
|
330
|
+
o.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css("paddingTop") || 0, 10) - parseInt(self.currentItem.css("paddingBottom") || 0, 10));
|
|
331
|
+
o.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css("paddingLeft") || 0, 10) - parseInt(self.currentItem.css("paddingRight") || 0, 10));
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
start: function () {
|
|
335
|
+
ts.grid.hDiv.scrollLeft = ts.grid.bDiv.scrollLeft;
|
|
336
|
+
},
|
|
337
|
+
update: function (event, ui) {
|
|
338
|
+
var th = $(">th", $(ui.item).parent()), tid1 = p.id + "_", permutation = [];
|
|
339
|
+
th.each(function () {
|
|
340
|
+
var id = $(">div", this).get(0).id.replace(/^jqgh_/, "").replace(tid1, ""),
|
|
341
|
+
iCol = p.iColByName[id];
|
|
342
|
+
if (iCol !== undefined) {
|
|
343
|
+
permutation.push(iCol);
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
$(ts).jqGrid("remapColumns", permutation, true, true);
|
|
348
|
+
if ($.jgrid.isFunction(p.sortable.update)) {
|
|
349
|
+
p.sortable.update(permutation);
|
|
350
|
+
}
|
|
351
|
+
setTimeout(function () { p.disableClick = false; }, 50);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
if (p.sortable.options) {
|
|
355
|
+
$.extend(sortableOpts, p.sortable.options);
|
|
356
|
+
} else if ($.jgrid.isFunction(p.sortable)) {
|
|
357
|
+
p.sortable = { "update": p.sortable };
|
|
358
|
+
}
|
|
359
|
+
if (sortableOpts.start) {
|
|
360
|
+
var s = sortableOpts.start;
|
|
361
|
+
sortableOpts.start = function (e, ui) {
|
|
362
|
+
start();
|
|
363
|
+
s.call(this, e, ui);
|
|
364
|
+
};
|
|
365
|
+
} else {
|
|
366
|
+
sortableOpts.start = start;
|
|
367
|
+
}
|
|
368
|
+
if (p.sortable.exclude) {
|
|
369
|
+
sortableOpts.items += ":not(" + p.sortable.exclude + ")";
|
|
370
|
+
}
|
|
371
|
+
var $e = tblrow.sortable(sortableOpts), dataObj = $e.data("sortable") || $e.data("uiSortable") || $e.data("ui-sortable");
|
|
372
|
+
if (dataObj != null) {
|
|
373
|
+
dataObj.floating = true;
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
columnChooser: function (opts) {
|
|
378
|
+
var $self = this, self = $self[0], p = self.p, selector, select, dopts, mopts,
|
|
379
|
+
$dialogContent, multiselectData, listHeight,
|
|
380
|
+
colModel = p.colModel, nCol = colModel.length, colNames = p.colNames,
|
|
381
|
+
getMultiselectWidgetData = function ($elem) {
|
|
382
|
+
return ($UiMultiselect && $UiMultiselect.prototype && $elem.data($UiMultiselect.prototype.widgetFullName || $UiMultiselect.prototype.widgetName)) ||
|
|
383
|
+
$elem.data("ui-multiselect") || $elem.data("multiselect");
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
if ($("#colchooser_" + jqID(p.id)).length) { return; }
|
|
387
|
+
selector = $('<div id="colchooser_' + p.id + '" style="position:relative;overflow:hidden"><div><select multiple="multiple"></select></div></div>');
|
|
388
|
+
select = $("select", selector);
|
|
389
|
+
|
|
390
|
+
function call(fn, obj) {
|
|
391
|
+
if (!fn) { return; }
|
|
392
|
+
if (typeof fn === "string") {
|
|
393
|
+
if ($.fn[fn]) {
|
|
394
|
+
$.fn[fn].apply(obj, $.makeArray(arguments).slice(2));
|
|
395
|
+
}
|
|
396
|
+
} else if ($.jgrid.isFunction(fn)) {
|
|
397
|
+
fn.apply(obj, $.makeArray(arguments).slice(2));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
opts = $.extend({
|
|
402
|
+
width: 400,
|
|
403
|
+
height: 240,
|
|
404
|
+
classname: null,
|
|
405
|
+
done: function (perm) {
|
|
406
|
+
if (perm) {
|
|
407
|
+
$self.jqGrid("remapColumns", perm, true);
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
/* msel is either the name of a ui widget class that
|
|
411
|
+
extends a multiselect, or a function that supports
|
|
412
|
+
creating a multiselect object (with no argument,
|
|
413
|
+
or when passed an object), and destroying it (when
|
|
414
|
+
passed the string "destroy"). */
|
|
415
|
+
msel: "multiselect",
|
|
416
|
+
/* "msel_opts" : {}, */
|
|
417
|
+
|
|
418
|
+
/* dlog is either the name of a ui widget class that
|
|
419
|
+
behaves in a dialog-like way, or a function, that
|
|
420
|
+
supports creating a dialog (when passed dlog_opts)
|
|
421
|
+
or destroying a dialog (when passed the string
|
|
422
|
+
"destroy")
|
|
423
|
+
*/
|
|
424
|
+
dlog: "dialog",
|
|
425
|
+
dialog_opts: {
|
|
426
|
+
minWidth: 470,
|
|
427
|
+
dialogClass: "ui-jqdialog"
|
|
428
|
+
},
|
|
429
|
+
/* dlog_opts is either an option object to be passed
|
|
430
|
+
to "dlog", or (more likely) a function that creates
|
|
431
|
+
the options object.
|
|
432
|
+
The default produces a suitable options object for
|
|
433
|
+
ui.dialog */
|
|
434
|
+
dlog_opts: function (options) {
|
|
435
|
+
var buttons = {};
|
|
436
|
+
buttons[options.bSubmit] = function () {
|
|
437
|
+
options.apply_perm();
|
|
438
|
+
options.cleanup(false);
|
|
439
|
+
};
|
|
440
|
+
buttons[options.bCancel] = function () {
|
|
441
|
+
options.cleanup(true);
|
|
442
|
+
};
|
|
443
|
+
return $.extend(true, {
|
|
444
|
+
buttons: buttons,
|
|
445
|
+
close: function () {
|
|
446
|
+
options.cleanup(true);
|
|
447
|
+
},
|
|
448
|
+
modal: options.modal || false,
|
|
449
|
+
resizable: options.resizable || true,
|
|
450
|
+
width: options.width + 70,
|
|
451
|
+
resize: function () {
|
|
452
|
+
var widgetData = getMultiselectWidgetData(select),
|
|
453
|
+
$thisDialogContent = widgetData.container.closest(".ui-dialog-content");
|
|
454
|
+
|
|
455
|
+
if ($thisDialogContent.length > 0 && typeof $thisDialogContent[0].style === "object") {
|
|
456
|
+
$thisDialogContent[0].style.width = "";
|
|
457
|
+
} else {
|
|
458
|
+
$thisDialogContent.css("width", ""); // or just remove width style
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
widgetData.selectedList.height(Math.max(widgetData.selectedContainer.height() - widgetData.selectedActions.outerHeight() - 1, 1));
|
|
462
|
+
widgetData.availableList.height(Math.max(widgetData.availableContainer.height() - widgetData.availableActions.outerHeight() - 1, 1));
|
|
463
|
+
}
|
|
464
|
+
}, options.dialog_opts || {});
|
|
465
|
+
},
|
|
466
|
+
/* Function to get the permutation array, and pass it to the
|
|
467
|
+
"done" function */
|
|
468
|
+
apply_perm: function () {
|
|
469
|
+
var perm = new Array(p.colModel.length), i, gHead,
|
|
470
|
+
showHideColOptions = {
|
|
471
|
+
notSkipFrozen: opts.notSkipFrozen === undefined ? false : opts.notSkipFrozen,
|
|
472
|
+
skipSetGridWidth: true,
|
|
473
|
+
skipSetGroupHeaders: true
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
// we can use remapColumnsByName instead of remapColumns in general,
|
|
477
|
+
// but we try to hold the compatibility with old version. Thus we
|
|
478
|
+
// fill perm based on multiselectData.newColOrder
|
|
479
|
+
for (i = 0; i < p.colModel.length; i++) {
|
|
480
|
+
perm[i] = p.iColByName[multiselectData.newColOrder[i]];
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
$("option", select).each(function () {
|
|
484
|
+
if ($(this).is(":selected")) {
|
|
485
|
+
$self.jqGrid("showCol", colModel[this.value].name, showHideColOptions);
|
|
486
|
+
} else {
|
|
487
|
+
$self.jqGrid("hideCol", colModel[this.value].name, showHideColOptions);
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
if (opts.done) {
|
|
492
|
+
opts.done.call($self, perm);
|
|
493
|
+
}
|
|
494
|
+
if (p.groupHeader && (typeof p.groupHeader === "object" || $.jgrid.isFunction(p.groupHeader))) {
|
|
495
|
+
$self.jqGrid("destroyGroupHeader", false);
|
|
496
|
+
p.groupHeader.groupHeaders = multiselectData.gh; // use modified groupHeader
|
|
497
|
+
if (p.pivotOptions != null && p.pivotOptions.colHeaders != null && p.pivotOptions.colHeaders.length > 1) {
|
|
498
|
+
gHead = p.pivotOptions.colHeaders;
|
|
499
|
+
for (i = 0; i < gHead.length; i++) {
|
|
500
|
+
// Multiple calls of setGroupHeaders for one grid are wrong,
|
|
501
|
+
// but there are produces good results in case of usage
|
|
502
|
+
// useColSpanStyle: false option. The rowspan values
|
|
503
|
+
// needed be increased in case of usage useColSpanStyle: true
|
|
504
|
+
if (gHead[i] && gHead[i].groupHeaders.length) {
|
|
505
|
+
$self.jqGrid("setGroupHeaders", gHead[i]);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
} else {
|
|
509
|
+
$self.jqGrid("setGroupHeaders", p.groupHeader);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
var newWidth = !p.autowidth && (p.widthOrg === undefined || p.widthOrg === "auto" || p.widthOrg === "100%") ? p.tblwidth : p.width;
|
|
513
|
+
if (newWidth !== p.width) {
|
|
514
|
+
$self.jqGrid("setGridWidth", newWidth, p.shrinkToFit);
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
/* Function to cleanup the dialog, and select. Also calls the
|
|
518
|
+
done function with no permutation (to indicate that the
|
|
519
|
+
columnChooser was aborted */
|
|
520
|
+
cleanup: function (calldone) {
|
|
521
|
+
call(opts.dlog, selector, "destroy");
|
|
522
|
+
call(opts.msel, select, "destroy");
|
|
523
|
+
selector.remove();
|
|
524
|
+
if (calldone && opts.done) {
|
|
525
|
+
opts.done.call($self);
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
msel_opts: {}
|
|
529
|
+
},
|
|
530
|
+
$self.jqGrid("getGridRes", "col"),
|
|
531
|
+
jgrid.col, opts || {});
|
|
532
|
+
if ($.ui) {
|
|
533
|
+
if ($UiMultiselect && $UiMultiselect.defaults) {
|
|
534
|
+
if (!jgrid._multiselect) {
|
|
535
|
+
// should be in language file
|
|
536
|
+
(jgrid.defaults != null && $.jgrid.isFunction(jgrid.defaults.fatalError) ? jgrid.defaults.fatalError : alert)("Multiselect plugin loaded after jqGrid. Please load the plugin before the jqGrid!");
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
// ??? the next line uses $.ui.multiselect.defaults which will be typically undefined
|
|
540
|
+
opts.msel_opts = $.extend($UiMultiselect.defaults, opts.msel_opts);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
if (opts.caption) {
|
|
544
|
+
selector.attr("title", opts.caption);
|
|
545
|
+
}
|
|
546
|
+
if (opts.classname) {
|
|
547
|
+
selector.addClass(opts.classname);
|
|
548
|
+
select.addClass(opts.classname);
|
|
549
|
+
}
|
|
550
|
+
if (opts.width) {
|
|
551
|
+
$(">div", selector).css({ width: opts.width, margin: "0 auto" });
|
|
552
|
+
select.css("width", opts.width);
|
|
553
|
+
}
|
|
554
|
+
if (opts.height) {
|
|
555
|
+
$(">div", selector).css("height", opts.height);
|
|
556
|
+
select.css("height", opts.height - 10);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
select.empty();
|
|
560
|
+
var gh = p.groupHeader != null ? p.groupHeader.groupHeaders : 0,
|
|
561
|
+
colHeader = {}, k, j, iCol, ghItem;
|
|
562
|
+
// fill colHeader for columns which have column header
|
|
563
|
+
if (gh) {
|
|
564
|
+
for (k = 0; k < gh.length; k++) {
|
|
565
|
+
ghItem = gh[k];
|
|
566
|
+
for (j = 0; j < ghItem.numberOfColumns; j++) {
|
|
567
|
+
iCol = p.iColByName[ghItem.startColumnName] + j;
|
|
568
|
+
colHeader[iCol] = $.jgrid.isFunction(opts.buildItemText) ?
|
|
569
|
+
opts.buildItemText.call($self[0], {
|
|
570
|
+
iCol: iCol,
|
|
571
|
+
cm: colModel[iCol],
|
|
572
|
+
cmName: colModel[iCol].name,
|
|
573
|
+
colName: colNames[iCol],
|
|
574
|
+
groupTitleText: ghItem.titleText
|
|
575
|
+
}) :
|
|
576
|
+
$.jgrid.stripHtml(ghItem.titleText) + ": " +
|
|
577
|
+
$.jgrid.stripHtml(colNames[iCol] === "" ? colModel[iCol].name : colNames[iCol]);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
// fill colHeader for all other columns
|
|
582
|
+
for (iCol = 0; iCol < nCol; iCol++) {
|
|
583
|
+
if (colHeader[iCol] === undefined) {
|
|
584
|
+
colHeader[iCol] = $.jgrid.isFunction(opts.buildItemText) ?
|
|
585
|
+
opts.buildItemText.call($self[0], {
|
|
586
|
+
iCol: iCol,
|
|
587
|
+
cm: colModel[iCol],
|
|
588
|
+
cmName: colModel[iCol].name,
|
|
589
|
+
colName: colNames[iCol],
|
|
590
|
+
groupTitleText: null
|
|
591
|
+
}) :
|
|
592
|
+
$.jgrid.stripHtml(colNames[iCol]);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
$.each(colModel, function (i) {
|
|
596
|
+
if (!this.hidedlg) {
|
|
597
|
+
select.append("<option value='" + i + "'" +
|
|
598
|
+
(p.headertitles || this.headerTitle ? (" title='" + jgrid.stripHtml(typeof this.headerTitle === "string" ? this.headerTitle : colHeader[i]) + "'") : "") +
|
|
599
|
+
(this.hidden ? "" : " selected='selected'") + ">" + colHeader[i] + "</option>");
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
dopts = $.jgrid.isFunction(opts.dlog_opts) ? opts.dlog_opts.call($self, opts) : opts.dlog_opts;
|
|
604
|
+
call(opts.dlog, selector, dopts);
|
|
605
|
+
mopts = $.jgrid.isFunction(opts.msel_opts) ? opts.msel_opts.call($self, opts) : opts.msel_opts;
|
|
606
|
+
call(opts.msel, select, mopts);
|
|
607
|
+
|
|
608
|
+
// fix height of elements of the multiselect widget
|
|
609
|
+
$dialogContent = $("#colchooser_" + jqID(p.id));
|
|
610
|
+
|
|
611
|
+
$dialogContent.css({ margin: "auto" });
|
|
612
|
+
$dialogContent.find(">div").css({ width: "100%", height: "100%", margin: "auto" });
|
|
613
|
+
|
|
614
|
+
multiselectData = getMultiselectWidgetData(select);
|
|
615
|
+
if (multiselectData) {
|
|
616
|
+
// grid property will be used to access the grid inside of _setSelected
|
|
617
|
+
multiselectData.grid = self;
|
|
618
|
+
if (gh) {
|
|
619
|
+
// make deep copy of groupHeaders to be able to hold changes of startColumnName,
|
|
620
|
+
// but to apply the changes only after the user click OK button (not Cancel)
|
|
621
|
+
multiselectData.gh = $.extend(true, [], gh);
|
|
622
|
+
|
|
623
|
+
// filling the helper array inGroup. It contains
|
|
624
|
+
// an item for every column. The value is undefined if the column
|
|
625
|
+
// not belongs to a header group and it is 0-based index of the
|
|
626
|
+
// header group (the index in gh array) if the column belongs to
|
|
627
|
+
// a header group. The array inGroup helps us to detect whether
|
|
628
|
+
// two columns belong to the same group or not.
|
|
629
|
+
multiselectData.inGroup = new Array(p.colModel.length); // allocate array with undefined values
|
|
630
|
+
|
|
631
|
+
var iGrp, headerItem;
|
|
632
|
+
for (iGrp = 0; iGrp < gh.length; iGrp++) {
|
|
633
|
+
headerItem = gh[iGrp];
|
|
634
|
+
for (iCol = 0; iCol < headerItem.numberOfColumns; iCol++) {
|
|
635
|
+
multiselectData.inGroup[p.iColByName[headerItem.startColumnName] + iCol] = iGrp;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
multiselectData.newColOrder = $.map(colModel, function (cm) { return cm.name; });
|
|
640
|
+
multiselectData.container.css({ width: "100%", height: "100%", margin: "auto" });
|
|
641
|
+
|
|
642
|
+
multiselectData.selectedContainer.css({ width: multiselectData.options.dividerLocation * 100 + "%", height: "100%", margin: "auto", boxSizing: "border-box" });
|
|
643
|
+
multiselectData.availableContainer.css({ width: (100 - multiselectData.options.dividerLocation * 100) + "%", height: "100%", margin: "auto", boxSizing: "border-box" });
|
|
644
|
+
|
|
645
|
+
// set height for both selectedList and availableList
|
|
646
|
+
multiselectData.selectedList.css("height", "auto");
|
|
647
|
+
multiselectData.availableList.css("height", "auto");
|
|
648
|
+
listHeight = Math.max(multiselectData.selectedList.height(), multiselectData.availableList.height());
|
|
649
|
+
listHeight = Math.min(listHeight, $(window).height());
|
|
650
|
+
multiselectData.selectedList.css("height", listHeight);
|
|
651
|
+
multiselectData.availableList.css("height", listHeight);
|
|
652
|
+
if (multiselectData.options != null && multiselectData.options.sortable) {
|
|
653
|
+
multiselectData.selectedList.on("sortupdate", function (e, ui) {
|
|
654
|
+
// remove fixed inline style values of width and height
|
|
655
|
+
// added during gragging
|
|
656
|
+
reorderSelectedColumns.call(
|
|
657
|
+
multiselectData,
|
|
658
|
+
parseInt(ui.item.data("optionLink").val(), 10)
|
|
659
|
+
);
|
|
660
|
+
ui.item.css({ width: "", height: "" });
|
|
661
|
+
if ($.jgrid.isFunction(opts.sortUpdate)) {
|
|
662
|
+
opts.sortUpdate.call(self, e, ui);
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
if ($.jgrid.isFunction(opts.init)) {
|
|
667
|
+
opts.init.call(self, multiselectData);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
},
|
|
671
|
+
sortableRows: function (opts) {
|
|
672
|
+
// Can accept all sortable options and events
|
|
673
|
+
return this.each(function () {
|
|
674
|
+
var $t = this, grid = $t.grid, p = $t.p;
|
|
675
|
+
if (!grid) { return; }
|
|
676
|
+
// Currently we disable a treeGrid sortable
|
|
677
|
+
if (p.treeGrid) { return; }
|
|
678
|
+
if ($.fn.sortable) {
|
|
679
|
+
opts = $.extend({
|
|
680
|
+
cursor: "move",
|
|
681
|
+
axis: "y",
|
|
682
|
+
items: ">tbody>.jqgrow"
|
|
683
|
+
},
|
|
684
|
+
opts || {});
|
|
685
|
+
if (opts.start && $.jgrid.isFunction(opts.start)) {
|
|
686
|
+
opts._start_ = opts.start;
|
|
687
|
+
delete opts.start;
|
|
688
|
+
} else { opts._start_ = false; }
|
|
689
|
+
if (opts.update && $.jgrid.isFunction(opts.update)) {
|
|
690
|
+
opts._update_ = opts.update;
|
|
691
|
+
delete opts.update;
|
|
692
|
+
} else { opts._update_ = false; }
|
|
693
|
+
opts.start = function (ev, ui) {
|
|
694
|
+
$(ui.item).css("border-width", "0");
|
|
695
|
+
$("td", ui.item).each(function (i) {
|
|
696
|
+
this.style.width = grid.cols[i].style.width;
|
|
697
|
+
});
|
|
698
|
+
if (p.subGrid) {
|
|
699
|
+
var subgid = $(ui.item).attr("id");
|
|
700
|
+
try {
|
|
701
|
+
$($t).jqGrid("collapseSubGridRow", subgid);
|
|
702
|
+
} catch (ignore) { }
|
|
703
|
+
}
|
|
704
|
+
if (opts._start_) {
|
|
705
|
+
opts._start_.apply(this, [ev, ui]);
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
opts.update = function (ev, ui) {
|
|
709
|
+
$(ui.item).css("border-width", "");
|
|
710
|
+
if (p.rownumbers === true) {
|
|
711
|
+
$("td.jqgrid-rownum", $t.rows).each(function (i) {
|
|
712
|
+
$(this).html(i + 1 + (parseInt(p.page, 10) - 1) * parseInt(p.rowNum, 10));
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
if (opts._update_) {
|
|
716
|
+
opts._update_.apply(this, [ev, ui]);
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
$($t).sortable(opts);
|
|
720
|
+
/*if ($.jgrid.isFunction($.fn.disableSelection)) {
|
|
721
|
+
// The method disableSelection exists starting with jQuery UI 1.6,
|
|
722
|
+
// but it's declared as deprecated since jQuery UI 1.9
|
|
723
|
+
// see http://jqueryui.com/upgrade-guide/1.9/#deprecated-disableselection-and-enableselection
|
|
724
|
+
// so we use disableSelection only if it exists
|
|
725
|
+
var jQueryUiVersion = $.ui != null && typeof $.ui.version === "string" ?
|
|
726
|
+
$.ui.version.match(/(\d+)\.(\d+).(\d+)/) : [];
|
|
727
|
+
// jQuery UI version is: jQueryUiVersion[1].jQueryUiVersion[2].jQueryUiVersion[3]
|
|
728
|
+
if (jQueryUiVersion.length === 4 && jQueryUiVersion[1] === "1" &&
|
|
729
|
+
jQueryUiVersion[2] > 5 && jQueryUiVersion[2] < 9) {
|
|
730
|
+
// disable selection only for old jQuery UI
|
|
731
|
+
$($t.tBodies[0]).children("tr.jqgrow").disableSelection();
|
|
732
|
+
}
|
|
733
|
+
}*/
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
},
|
|
737
|
+
gridDnD: function (opts) {
|
|
738
|
+
return this.each(function () {
|
|
739
|
+
var $t = this, j, cn;
|
|
740
|
+
if (!$t.grid) { return; }
|
|
741
|
+
// Currently we disable a treeGrid drag and drop
|
|
742
|
+
if ($t.p.treeGrid) { return; }
|
|
743
|
+
if (!$.fn.draggable || !$.fn.droppable) { return; }
|
|
744
|
+
function updateDnD() {
|
|
745
|
+
var datadnd = $.data($t, "dnd");
|
|
746
|
+
$("tr.jqgrow:not(.ui-draggable)", $t).draggable($.jgrid.isFunction(datadnd.drag) ? datadnd.drag.call($($t), datadnd) : datadnd.drag);
|
|
747
|
+
}
|
|
748
|
+
var appender = "<table id='jqgrid_dnd' class='ui-jqgrid-dnd'></table>";
|
|
749
|
+
if ($("#jqgrid_dnd")[0] === undefined) {
|
|
750
|
+
$("body").append(appender);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (typeof opts === "string" && opts === "updateDnD" && $t.p.jqgdnd === true) {
|
|
754
|
+
updateDnD();
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
opts = $.extend({
|
|
758
|
+
drag: function (opts1) {
|
|
759
|
+
return $.extend({
|
|
760
|
+
start: function (ev, ui) {
|
|
761
|
+
var i, subgid;
|
|
762
|
+
// if we are in subgrid mode try to collapse the node
|
|
763
|
+
if ($t.p.subGrid) {
|
|
764
|
+
subgid = $(ui.helper).attr("id");
|
|
765
|
+
try {
|
|
766
|
+
$($t).jqGrid("collapseSubGridRow", subgid);
|
|
767
|
+
} catch (ignore) { }
|
|
768
|
+
}
|
|
769
|
+
// hack
|
|
770
|
+
// drag and drop does not insert tr in table, when the table has no rows
|
|
771
|
+
// we try to insert new empty row on the target(s)
|
|
772
|
+
for (i = 0; i < $.data($t, "dnd").connectWith.length; i++) {
|
|
773
|
+
if ($($.data($t, "dnd").connectWith[i]).jqGrid("getGridParam", "reccount") === 0) {
|
|
774
|
+
$($.data($t, "dnd").connectWith[i]).jqGrid("addRowData", "jqg_empty_row", {});
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
ui.helper.addClass("ui-state-highlight");
|
|
778
|
+
$("td", ui.helper).each(function (iCol) {
|
|
779
|
+
this.style.width = $t.grid.headers[iCol].width + "px";
|
|
780
|
+
});
|
|
781
|
+
if (opts1.onstart && $.jgrid.isFunction(opts1.onstart)) { opts1.onstart.call($($t), ev, ui); }
|
|
782
|
+
},
|
|
783
|
+
stop: function (ev, ui) {
|
|
784
|
+
var i, ids;
|
|
785
|
+
if (ui.helper.dropped && !opts1.dragcopy) {
|
|
786
|
+
ids = $(ui.helper).attr("id");
|
|
787
|
+
if (ids === undefined) { ids = $(this).attr("id"); }
|
|
788
|
+
$($t).jqGrid("delRowData", ids);
|
|
789
|
+
}
|
|
790
|
+
// if we have a empty row inserted from start event try to delete it
|
|
791
|
+
for (i = 0; i < $.data($t, "dnd").connectWith.length; i++) {
|
|
792
|
+
$($.data($t, "dnd").connectWith[i]).jqGrid("delRowData", "jqg_empty_row");
|
|
793
|
+
}
|
|
794
|
+
if (opts1.onstop && $.jgrid.isFunction(opts1.onstop)) { opts1.onstop.call($($t), ev, ui); }
|
|
795
|
+
}
|
|
796
|
+
}, opts1.drag_opts || {});
|
|
797
|
+
},
|
|
798
|
+
drop: function (opts1) {
|
|
799
|
+
return $.extend({
|
|
800
|
+
accept: function (d) {
|
|
801
|
+
if (!$(d).hasClass("jqgrow")) { return d; }
|
|
802
|
+
var tid = $(d).closest("table.ui-jqgrid-btable");
|
|
803
|
+
if (tid.length > 0 && $.data(tid[0], "dnd") !== undefined) {
|
|
804
|
+
var cn1 = $.data(tid[0], "dnd").connectWith;
|
|
805
|
+
return $.inArray("#" + jqID(this.id), cn1) !== -1 ? true : false;
|
|
806
|
+
}
|
|
807
|
+
return false;
|
|
808
|
+
},
|
|
809
|
+
drop: function (ev, ui) {
|
|
810
|
+
if (!$(ui.draggable).hasClass("jqgrow")) { return; }
|
|
811
|
+
var rowid = $(ui.draggable).attr("id"),
|
|
812
|
+
$srcGrid = ui.draggable.parent().parent(),
|
|
813
|
+
getdata = $srcGrid.jqGrid("getRowData", rowid);
|
|
814
|
+
if (!opts1.dropbyname) {
|
|
815
|
+
var tmpdata = {}, iSrc, iDest, srcName, destName,
|
|
816
|
+
srcColModel = $srcGrid.jqGrid("getGridParam", "colModel"),
|
|
817
|
+
destColModel = $("#" + jqID(this.id)).jqGrid("getGridParam", "colModel");
|
|
818
|
+
try {
|
|
819
|
+
for (iSrc = 0, iDest = 0; iSrc < srcColModel.length && iDest < destColModel.length; iSrc++) {
|
|
820
|
+
srcName = srcColModel[iSrc].name;
|
|
821
|
+
if (!(srcName === "cb" || srcName === "rn" || srcName === "subgrid")) {
|
|
822
|
+
// src column found, which need be copied
|
|
823
|
+
for (; iDest < destColModel.length; iDest++) {
|
|
824
|
+
destName = destColModel[iDest].name;
|
|
825
|
+
if (!(destName === "cb" || destName === "rn" || destName === "subgrid")) {
|
|
826
|
+
tmpdata[destName] = getdata[srcName];
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
iDest++;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
getdata = tmpdata;
|
|
834
|
+
} catch (ignore) { }
|
|
835
|
+
}
|
|
836
|
+
ui.helper.dropped = true;
|
|
837
|
+
if (opts1.beforedrop && $.jgrid.isFunction(opts1.beforedrop)) {
|
|
838
|
+
//parameters to this callback - event, element, data to be inserted, sender, reciever
|
|
839
|
+
// should return object which will be inserted into the reciever
|
|
840
|
+
var datatoinsert = opts1.beforedrop.call(this, ev, ui, getdata, $("#" + jqID($t.p.id)), $(this));
|
|
841
|
+
if (datatoinsert !== undefined && datatoinsert !== null && typeof datatoinsert === "object") { getdata = datatoinsert; }
|
|
842
|
+
}
|
|
843
|
+
if (ui.helper.dropped) {
|
|
844
|
+
var grid;
|
|
845
|
+
if (opts1.autoid) {
|
|
846
|
+
if ($.jgrid.isFunction(opts1.autoid)) {
|
|
847
|
+
grid = opts1.autoid.call(this, getdata, {
|
|
848
|
+
rowid: rowid,
|
|
849
|
+
ev: ev,
|
|
850
|
+
ui: ui
|
|
851
|
+
});
|
|
852
|
+
} else {
|
|
853
|
+
grid = Math.ceil(Math.random() * 1000);
|
|
854
|
+
grid = opts1.autoidprefix + grid;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
// NULL is interpreted as undefined while null as object
|
|
858
|
+
$("#" + jqID(this.id)).jqGrid("addRowData", grid, getdata, opts1.droppos);
|
|
859
|
+
getdata[$t.p.localReader.id] = grid;
|
|
860
|
+
}
|
|
861
|
+
if (opts1.ondrop && $.jgrid.isFunction(opts1.ondrop)) { opts1.ondrop.call(this, ev, ui, getdata); }
|
|
862
|
+
}
|
|
863
|
+
}, opts1.drop_opts || {});
|
|
864
|
+
},
|
|
865
|
+
onstart: null,
|
|
866
|
+
onstop: null,
|
|
867
|
+
beforedrop: null,
|
|
868
|
+
ondrop: null,
|
|
869
|
+
drop_opts: {
|
|
870
|
+
//activeClass: "ui-state-active",
|
|
871
|
+
//hoverClass: "ui-state-hover"
|
|
872
|
+
},
|
|
873
|
+
drag_opts: {
|
|
874
|
+
revert: "invalid",
|
|
875
|
+
helper: "clone",
|
|
876
|
+
cursor: "move",
|
|
877
|
+
appendTo: "#jqgrid_dnd",
|
|
878
|
+
zIndex: 5000
|
|
879
|
+
},
|
|
880
|
+
dragcopy: false,
|
|
881
|
+
dropbyname: false,
|
|
882
|
+
droppos: "first",
|
|
883
|
+
autoid: true,
|
|
884
|
+
autoidprefix: "dnd_"
|
|
885
|
+
}, opts || {});
|
|
886
|
+
|
|
887
|
+
if (!opts.connectWith) { return; }
|
|
888
|
+
opts.connectWith = opts.connectWith.split(",");
|
|
889
|
+
opts.connectWith = $.map(opts.connectWith, function (n) { return $.jgrid.trim(n); });
|
|
890
|
+
$.data($t, "dnd", opts);
|
|
891
|
+
|
|
892
|
+
if ($t.p.reccount !== 0 && !$t.p.jqgdnd) {
|
|
893
|
+
updateDnD();
|
|
894
|
+
}
|
|
895
|
+
$t.p.jqgdnd = true;
|
|
896
|
+
for (j = 0; j < opts.connectWith.length; j++) {
|
|
897
|
+
cn = opts.connectWith[j];
|
|
898
|
+
$(cn).droppable($.jgrid.isFunction(opts.drop) ? opts.drop.call($($t), opts) : opts.drop);
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
},
|
|
902
|
+
gridResize: function (opts) {
|
|
903
|
+
return this.each(function () {
|
|
904
|
+
var $t = this, grid = $t.grid, p = $t.p, bdivSelector = p.gView + ">.ui-jqgrid-bdiv", onlyHorizontal = false, sel, gridHeight = p.height;
|
|
905
|
+
if (!grid || !$.fn.resizable) { return; }
|
|
906
|
+
opts = $.extend({}, opts || {});
|
|
907
|
+
if (opts.alsoResize) {
|
|
908
|
+
opts._alsoResize_ = opts.alsoResize;
|
|
909
|
+
delete opts.alsoResize;
|
|
910
|
+
} else {
|
|
911
|
+
opts._alsoResize_ = false;
|
|
912
|
+
}
|
|
913
|
+
if (opts.stop && $.jgrid.isFunction(opts.stop)) {
|
|
914
|
+
opts._stop_ = opts.stop;
|
|
915
|
+
delete opts.stop;
|
|
916
|
+
} else {
|
|
917
|
+
opts._stop_ = false;
|
|
918
|
+
}
|
|
919
|
+
opts.stop = function (ev, ui) {
|
|
920
|
+
$($t).jqGrid("setGridWidth", ui.size.width, opts.shrinkToFit);
|
|
921
|
+
$(p.gView + ">.ui-jqgrid-titlebar").css("width", "");
|
|
922
|
+
if (!onlyHorizontal) {
|
|
923
|
+
$($t).jqGrid("setGridParam", { height: $(bdivSelector).height() });
|
|
924
|
+
} else {
|
|
925
|
+
$(sel).each(function () {
|
|
926
|
+
$(this).css("height", "");
|
|
927
|
+
});
|
|
928
|
+
if (gridHeight === "auto" || gridHeight === "100%") {
|
|
929
|
+
$(grid.bDiv).css("height", gridHeight);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
if ($t.fixScrollOffsetAndhBoxPadding) {
|
|
933
|
+
$t.fixScrollOffsetAndhBoxPadding();
|
|
934
|
+
}
|
|
935
|
+
if (opts._stop_) { opts._stop_.call($t, ev, ui); }
|
|
936
|
+
};
|
|
937
|
+
sel = bdivSelector;
|
|
938
|
+
if ((gridHeight === "auto" || gridHeight === "100%") && opts.handles === undefined) {
|
|
939
|
+
opts.handles = "e,w";
|
|
940
|
+
}
|
|
941
|
+
if (opts.handles) {
|
|
942
|
+
// test for "e, w"
|
|
943
|
+
var ar = $.map(String(opts.handles).split(","), function (item) {
|
|
944
|
+
return $.jgrid.trim(item);
|
|
945
|
+
});
|
|
946
|
+
if (ar.length === 2 && ((ar[0] === "e" && ar[1] === "w") || (ar[1] === "e" && ar[1] === "w"))) {
|
|
947
|
+
sel = p.gView + ">div:not(.frozen-div)";
|
|
948
|
+
onlyHorizontal = true;
|
|
949
|
+
if (p.pager) {
|
|
950
|
+
sel += "," + p.pager;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
if (opts._alsoResize_) {
|
|
955
|
+
opts.alsoResize = sel + "," + opts._alsoResize_;
|
|
956
|
+
} else {
|
|
957
|
+
opts.alsoResize = sel;
|
|
958
|
+
}
|
|
959
|
+
delete opts._alsoResize_;
|
|
960
|
+
$(p.gBox).resizable(opts);
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
// end module grid.jqueryui
|
|
965
|
+
}));
|