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,897 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* jqFilter jQuery jqGrid filter addon.
|
|
3
|
+
* Copyright (c) 2011-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
|
+
* The work is inspired from this Stefan Pirvu
|
|
11
|
+
* http://www.codeproject.com/KB/scripting/json-filtering.aspx
|
|
12
|
+
**/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The filter uses JSON entities to hold filter rules and groups. Here is an example of a filter:
|
|
16
|
+
|
|
17
|
+
{ "groupOp": "AND",
|
|
18
|
+
"groups" : [
|
|
19
|
+
{ "groupOp": "OR",
|
|
20
|
+
"rules": [
|
|
21
|
+
{ "field": "name", "op": "eq", "data": "England" },
|
|
22
|
+
{ "field": "id", "op": "le", "data": "5"}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"rules": [
|
|
27
|
+
{ "field": "name", "op": "eq", "data": "Romania" },
|
|
28
|
+
{ "field": "id", "op": "le", "data": "1"}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/*jshint eqeqeq:false, eqnull:true, devel:true */
|
|
34
|
+
/*jslint browser: true, devel: true, eqeq: true, plusplus: true, vars: true, white: true */
|
|
35
|
+
/*global jQuery, define, exports, module, require */
|
|
36
|
+
|
|
37
|
+
(function (global, factory) {
|
|
38
|
+
"use strict";
|
|
39
|
+
if (typeof define === "function" && define.amd) {
|
|
40
|
+
// AMD. Register as an anonymous module.
|
|
41
|
+
//console.log("grid.filter AMD");
|
|
42
|
+
define([
|
|
43
|
+
"jquery",
|
|
44
|
+
"./grid.base",
|
|
45
|
+
"./grid.common"
|
|
46
|
+
], function ($) {
|
|
47
|
+
//console.log("grid.filter AMD: define callback");
|
|
48
|
+
return factory($, global);
|
|
49
|
+
});
|
|
50
|
+
} else if (typeof module === "object" && module.exports) {
|
|
51
|
+
// Node/CommonJS
|
|
52
|
+
//console.log("grid.filter CommonJS, typeof define=" + typeof define + ", define=" + define);
|
|
53
|
+
module.exports = function (root, $) {
|
|
54
|
+
//console.log("grid.filter CommonJS: in module.exports");
|
|
55
|
+
if (!root) {
|
|
56
|
+
root = window;
|
|
57
|
+
}
|
|
58
|
+
//console.log("grid.filter CommonJS: before require('jquery')");
|
|
59
|
+
if ($ === undefined) {
|
|
60
|
+
// require("jquery") returns a factory that requires window to
|
|
61
|
+
// build a jQuery instance, we normalize how we use modules
|
|
62
|
+
// that require this pattern but the window provided is a noop
|
|
63
|
+
// if it's defined (how jquery works)
|
|
64
|
+
$ = typeof window !== "undefined" ?
|
|
65
|
+
require("jquery") :
|
|
66
|
+
require("jquery")(root);
|
|
67
|
+
}
|
|
68
|
+
//console.log("grid.filter CommonJS: before require('./grid.base')");
|
|
69
|
+
require("./grid.base");
|
|
70
|
+
//console.log("grid.filter CommonJS: before require('./grid.common')");
|
|
71
|
+
require("./grid.common");
|
|
72
|
+
factory($, root);
|
|
73
|
+
return $;
|
|
74
|
+
};
|
|
75
|
+
} else {
|
|
76
|
+
// Browser globals
|
|
77
|
+
//console.log("grid.filter Browser: before factory");
|
|
78
|
+
factory(jQuery, global);
|
|
79
|
+
}
|
|
80
|
+
}(typeof window !== "undefined" ? window : this, function ($, window) {
|
|
81
|
+
"use strict";
|
|
82
|
+
var jgrid = $.jgrid;
|
|
83
|
+
// begin module grid.filter
|
|
84
|
+
$.fn.jqFilter = function (arg) {
|
|
85
|
+
if (typeof arg === "string") {
|
|
86
|
+
var fn = $.fn.jqFilter[arg];
|
|
87
|
+
if (!fn) {
|
|
88
|
+
throw ("jqFilter - No such method: " + arg);
|
|
89
|
+
}
|
|
90
|
+
var args = $.makeArray(arguments).slice(1);
|
|
91
|
+
return fn.apply(this, args);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
var p = $.extend(true, {
|
|
95
|
+
filter: null,
|
|
96
|
+
columns: [],
|
|
97
|
+
onChange: null,
|
|
98
|
+
afterRedraw: null,
|
|
99
|
+
error: false,
|
|
100
|
+
errmsg: "",
|
|
101
|
+
errorcheck: true,
|
|
102
|
+
showQuery: true,
|
|
103
|
+
sopt: null,
|
|
104
|
+
ops: [],
|
|
105
|
+
operands: null,
|
|
106
|
+
numopts: ["eq", "ne", "lt", "le", "gt", "ge", "nu", "nn", "in", "ni"],
|
|
107
|
+
stropts: ["eq", "ne", "bw", "bn", "ew", "en", "cn", "nc", "nu", "nn", "in", "ni"],
|
|
108
|
+
strarr: ["text", "string", "blob"],
|
|
109
|
+
groupOps: [{ op: "AND", text: "AND" }, { op: "OR", text: "OR" }],
|
|
110
|
+
groupButton: true,
|
|
111
|
+
ruleButtons: true,
|
|
112
|
+
direction: "ltr"
|
|
113
|
+
}, jgrid.filter, arg || {});
|
|
114
|
+
return this.each(function () {
|
|
115
|
+
if (this.filter) { return; }
|
|
116
|
+
this.p = p;
|
|
117
|
+
// setup filter in case if they is not defined
|
|
118
|
+
if (p.filter === null || p.filter === undefined) {
|
|
119
|
+
p.filter = {
|
|
120
|
+
groupOp: p.groupOps[0].op,
|
|
121
|
+
rules: [],
|
|
122
|
+
groups: []
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
var iColumn, len = p.columns.length, cl, isIE = /msie/i.test(navigator.userAgent) && !window.opera,
|
|
126
|
+
isFunction = $.jgrid.isFunction,
|
|
127
|
+
fatalErrorFunction = jgrid.defaults != null && isFunction(jgrid.defaults.fatalError) ? jgrid.defaults.fatalError : alert,
|
|
128
|
+
getGrid = function () {
|
|
129
|
+
return $("#" + jgrid.jqID(p.id))[0] || null;
|
|
130
|
+
},
|
|
131
|
+
getGuiStyles = function (path, jqClasses) {
|
|
132
|
+
return $(getGrid()).jqGrid("getGuiStyles", path, jqClasses || "");
|
|
133
|
+
},
|
|
134
|
+
getRes = function (property) {
|
|
135
|
+
return $(getGrid()).jqGrid("getGridRes", "search." + property);
|
|
136
|
+
},
|
|
137
|
+
getCmInfo = function (cmName) {
|
|
138
|
+
// the function convert column name or advanced property name to
|
|
139
|
+
// object with properties { cm: , iCol: }
|
|
140
|
+
var $t = getGrid(), iCol = $t.p.iColByName[cmName]; //iPropByName
|
|
141
|
+
if (iCol !== undefined) {
|
|
142
|
+
return { cm: $t.p.colModel[iCol], iCol: iCol };
|
|
143
|
+
}
|
|
144
|
+
iCol = $t.p.iPropByName[cmName];
|
|
145
|
+
if (iCol !== undefined) {
|
|
146
|
+
return { cm: $t.p.additionalProperties[iCol], iCol: iCol, isAddProp: true };
|
|
147
|
+
}
|
|
148
|
+
return { cm: null, iCol: -1 };
|
|
149
|
+
},
|
|
150
|
+
errorClass = getGuiStyles("states.error"),
|
|
151
|
+
dialogContentClass = getGuiStyles("dialog.content");
|
|
152
|
+
|
|
153
|
+
// translating the options
|
|
154
|
+
p.initFilter = $.extend(true, {}, p.filter);
|
|
155
|
+
|
|
156
|
+
// set default values for the columns if they are not set
|
|
157
|
+
if (!len) { return; }
|
|
158
|
+
for (iColumn = 0; iColumn < len; iColumn++) {
|
|
159
|
+
cl = p.columns[iColumn];
|
|
160
|
+
if (cl.stype) {
|
|
161
|
+
// grid compatibility
|
|
162
|
+
cl.inputtype = cl.stype;
|
|
163
|
+
} else if (!cl.inputtype) {
|
|
164
|
+
cl.inputtype = "text";
|
|
165
|
+
}
|
|
166
|
+
if (cl.sorttype) {
|
|
167
|
+
// grid compatibility
|
|
168
|
+
cl.searchtype = cl.sorttype;
|
|
169
|
+
} else if (!cl.searchtype) {
|
|
170
|
+
cl.searchtype = "string";
|
|
171
|
+
}
|
|
172
|
+
if (cl.hidden === undefined) {
|
|
173
|
+
// jqGrid compatibility
|
|
174
|
+
cl.hidden = false;
|
|
175
|
+
}
|
|
176
|
+
if (!cl.label) {
|
|
177
|
+
cl.label = cl.name;
|
|
178
|
+
}
|
|
179
|
+
cl.cmName = cl.name;
|
|
180
|
+
if (cl.index) {
|
|
181
|
+
cl.name = cl.index;
|
|
182
|
+
}
|
|
183
|
+
if (!cl.hasOwnProperty("searchoptions")) {
|
|
184
|
+
cl.searchoptions = {};
|
|
185
|
+
}
|
|
186
|
+
if (!cl.hasOwnProperty("searchrules")) {
|
|
187
|
+
cl.searchrules = {};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
if (p.showQuery) {
|
|
192
|
+
$(this).append("<table class='queryresult " + dialogContentClass +
|
|
193
|
+
"' style='display:block;max-width:440px;border:0px none;' dir='" + p.direction + "'><tbody><tr><td class='query'></td></tr></tbody></table>");
|
|
194
|
+
}
|
|
195
|
+
/*
|
|
196
|
+
*Perform checking.
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
var checkData = function (val, colModelItem) {
|
|
200
|
+
var ret = [true, ""], $t = getGrid();
|
|
201
|
+
if (isFunction(colModelItem.searchrules)) {
|
|
202
|
+
ret = colModelItem.searchrules.call($t, val, colModelItem);
|
|
203
|
+
} else if (jgrid && jgrid.checkValues) {
|
|
204
|
+
try {
|
|
205
|
+
ret = jgrid.checkValues.call($t, val, -1, colModelItem.searchrules, colModelItem.label);
|
|
206
|
+
} catch (ignore) { }
|
|
207
|
+
}
|
|
208
|
+
if (ret && ret.length && ret[0] === false) {
|
|
209
|
+
p.error = !ret[0];
|
|
210
|
+
p.errmsg = ret[1];
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
/* moving to common
|
|
214
|
+
randId = function() {
|
|
215
|
+
return Math.floor(Math.random()*10000).toString();
|
|
216
|
+
};
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
this.onchange = function () {
|
|
220
|
+
// clear any error
|
|
221
|
+
p.error = false;
|
|
222
|
+
p.errmsg = "";
|
|
223
|
+
return isFunction(p.onChange) ? p.onChange.call(getGrid(), p, this) : false;
|
|
224
|
+
};
|
|
225
|
+
/*
|
|
226
|
+
* Redraw the filter every time when new field is added/deleted
|
|
227
|
+
* and field is changed
|
|
228
|
+
*/
|
|
229
|
+
this.reDraw = function () {
|
|
230
|
+
$("table.group:first", this).remove();
|
|
231
|
+
var t = this.createTableForGroup(p.filter, null);
|
|
232
|
+
$(this).append(t);
|
|
233
|
+
if (isFunction(p.afterRedraw)) {
|
|
234
|
+
p.afterRedraw.call(getGrid(), p, this);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Creates a grouping data for the filter
|
|
239
|
+
* @param group - object
|
|
240
|
+
* @param parentgroup - object
|
|
241
|
+
*/
|
|
242
|
+
this.createTableForGroup = function (group, parentgroup) {
|
|
243
|
+
var that = this, i;
|
|
244
|
+
// this table will hold all the group (tables) and rules (rows)
|
|
245
|
+
var table = $("<table class='" + getGuiStyles("searchDialog.operationGroup", "group") +
|
|
246
|
+
"' style='border:0px none;'><tbody></tbody></table>"), align = "left";
|
|
247
|
+
// create error message row
|
|
248
|
+
if (p.direction === "rtl") {
|
|
249
|
+
align = "right";
|
|
250
|
+
table.attr("dir", "rtl");
|
|
251
|
+
}
|
|
252
|
+
if (parentgroup === null) {
|
|
253
|
+
table.append("<tr class='error' style='display:none;'><th colspan='5' class='" + errorClass + "' align='" + align + "'></th></tr>");
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
var tr = $("<tr></tr>");
|
|
257
|
+
table.append(tr);
|
|
258
|
+
// this header will hold the group operator type and group action buttons for
|
|
259
|
+
// creating subgroup "+ {}", creating rule "+" or deleting the group "-"
|
|
260
|
+
var th = $("<th colspan='5' align='" + align + "'></th>");
|
|
261
|
+
tr.append(th);
|
|
262
|
+
|
|
263
|
+
if (p.ruleButtons === true) {
|
|
264
|
+
// dropdown for: choosing group operator type
|
|
265
|
+
var groupOpSelect = $("<select class='" + getGuiStyles("searchDialog.operationSelect", "opsel") + "'></select>");
|
|
266
|
+
th.append(groupOpSelect);
|
|
267
|
+
// populate dropdown with all posible group operators: or, and
|
|
268
|
+
var str = "", selected;
|
|
269
|
+
for (i = 0; i < p.groupOps.length; i++) {
|
|
270
|
+
selected = group.groupOp === that.p.groupOps[i].op ? " selected='selected'" : "";
|
|
271
|
+
str += "<option value='" + that.p.groupOps[i].op + "'" + selected + ">" + that.p.groupOps[i].text + "</option>";
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
groupOpSelect.append(str)
|
|
275
|
+
.on("change", function () {
|
|
276
|
+
group.groupOp = $(groupOpSelect).val();
|
|
277
|
+
that.onchange(); // signals that the filter has changed
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
// button for adding a new subgroup
|
|
281
|
+
var inputAddSubgroup = "<span></span>";
|
|
282
|
+
if (p.groupButton) {
|
|
283
|
+
inputAddSubgroup = $("<input type='button' value='+ {}' title='" + getRes("addGroupTitle") + "' class='" +
|
|
284
|
+
getGuiStyles("searchDialog.addGroupButton", "add-group") + "'/>");
|
|
285
|
+
inputAddSubgroup.on("click", function () {
|
|
286
|
+
if (group.groups === undefined) {
|
|
287
|
+
group.groups = [];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
group.groups.push({
|
|
291
|
+
groupOp: p.groupOps[0].op,
|
|
292
|
+
rules: [],
|
|
293
|
+
groups: []
|
|
294
|
+
}); // adding a new group
|
|
295
|
+
|
|
296
|
+
that.reDraw(); // the html has changed, force reDraw
|
|
297
|
+
|
|
298
|
+
that.onchange(); // signals that the filter has changed
|
|
299
|
+
return false;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
th.append(inputAddSubgroup);
|
|
303
|
+
if (p.ruleButtons === true) {
|
|
304
|
+
// button for adding a new rule
|
|
305
|
+
var inputAddRule = $("<input type='button' value='+' title='" + getRes("addRuleTitle") + "' class='" +
|
|
306
|
+
getGuiStyles("searchDialog.addRuleButton", "add-rule ui-add") + "'/>"), cm;
|
|
307
|
+
inputAddRule.on("click", function () {
|
|
308
|
+
var searchable, hidden, ignoreHiding;
|
|
309
|
+
//if(!group) { group = {};}
|
|
310
|
+
if (group.rules === undefined) {
|
|
311
|
+
group.rules = [];
|
|
312
|
+
}
|
|
313
|
+
for (i = 0; i < that.p.columns.length; i++) {
|
|
314
|
+
// but show only serchable and serchhidden = true fields
|
|
315
|
+
searchable = (that.p.columns[i].search === undefined) ? true : that.p.columns[i].search;
|
|
316
|
+
hidden = (that.p.columns[i].hidden === true);
|
|
317
|
+
ignoreHiding = (that.p.columns[i].searchoptions.searchhidden === true);
|
|
318
|
+
if ((ignoreHiding && searchable) || (searchable && !hidden)) {
|
|
319
|
+
cm = that.p.columns[i];
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
var opr;
|
|
325
|
+
if (cm.searchoptions.sopt) {
|
|
326
|
+
opr = cm.searchoptions.sopt;
|
|
327
|
+
} else if (that.p.sopt) {
|
|
328
|
+
opr = that.p.sopt;
|
|
329
|
+
} else if ($.inArray(cm.searchtype, that.p.strarr) !== -1) {
|
|
330
|
+
opr = that.p.stropts;
|
|
331
|
+
} else {
|
|
332
|
+
opr = that.p.numopts;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
group.rules.push({
|
|
336
|
+
field: cm.name,
|
|
337
|
+
op: opr[0],
|
|
338
|
+
data: ""
|
|
339
|
+
}); // adding a new rule
|
|
340
|
+
|
|
341
|
+
that.reDraw(); // the html has changed, force reDraw
|
|
342
|
+
// for the moment no change have been made to the rule, so
|
|
343
|
+
// this will not trigger onchange event
|
|
344
|
+
return false;
|
|
345
|
+
});
|
|
346
|
+
th.append(inputAddRule);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// button for delete the group
|
|
350
|
+
if (parentgroup !== null) { // ignore the first group
|
|
351
|
+
var inputDeleteGroup = $("<input type='button' value='-' title='" + getRes("deleteGroupTitle") + "' class='" +
|
|
352
|
+
getGuiStyles("searchDialog.deleteGroupButton", "delete-group") + "'/>");
|
|
353
|
+
th.append(inputDeleteGroup);
|
|
354
|
+
inputDeleteGroup.on("click", function () {
|
|
355
|
+
// remove group from parent
|
|
356
|
+
for (i = 0; i < parentgroup.groups.length; i++) {
|
|
357
|
+
if (parentgroup.groups[i] === group) {
|
|
358
|
+
parentgroup.groups.splice(i, 1);
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
that.reDraw(); // the html has changed, force reDraw
|
|
364
|
+
|
|
365
|
+
that.onchange(); // signals that the filter has changed
|
|
366
|
+
return false;
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// append subgroup rows
|
|
371
|
+
if (group.groups !== undefined) {
|
|
372
|
+
var trHolderForSubgroup, tdFirstHolderForSubgroup, tdMainHolderForSubgroup;
|
|
373
|
+
for (i = 0; i < group.groups.length; i++) {
|
|
374
|
+
trHolderForSubgroup = $("<tr></tr>");
|
|
375
|
+
table.append(trHolderForSubgroup);
|
|
376
|
+
|
|
377
|
+
tdFirstHolderForSubgroup = $("<td class='first'></td>");
|
|
378
|
+
trHolderForSubgroup.append(tdFirstHolderForSubgroup);
|
|
379
|
+
|
|
380
|
+
tdMainHolderForSubgroup = $("<td colspan='4'></td>");
|
|
381
|
+
tdMainHolderForSubgroup.append(this.createTableForGroup(group.groups[i], group));
|
|
382
|
+
trHolderForSubgroup.append(tdMainHolderForSubgroup);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (group.groupOp === undefined) {
|
|
386
|
+
group.groupOp = that.p.groupOps[0].op;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// append rules rows
|
|
390
|
+
if (group.rules !== undefined) {
|
|
391
|
+
for (i = 0; i < group.rules.length; i++) {
|
|
392
|
+
table.append(
|
|
393
|
+
this.createTableRowForRule(group.rules[i], group)
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return table;
|
|
399
|
+
};
|
|
400
|
+
/*
|
|
401
|
+
* Create the rule data for the filter
|
|
402
|
+
*/
|
|
403
|
+
this.createTableRowForRule = function (rule, group) {
|
|
404
|
+
// save current entity in a variable so that it could
|
|
405
|
+
// be referenced in anonimous method calls
|
|
406
|
+
|
|
407
|
+
var that = this, $t = getGrid(), tr = $("<tr></tr>"),
|
|
408
|
+
i, op, cm, str = "", selected;
|
|
409
|
+
|
|
410
|
+
tr.append("<td class='first'></td>");
|
|
411
|
+
|
|
412
|
+
// create field container
|
|
413
|
+
var ruleFieldTd = $("<td class='columns'></td>");
|
|
414
|
+
tr.append(ruleFieldTd);
|
|
415
|
+
|
|
416
|
+
// dropdown for: choosing field
|
|
417
|
+
var ruleFieldSelect = $("<select class='" + getGuiStyles("searchDialog.label", "selectLabel") +
|
|
418
|
+
"'></select>"), ina, aoprs = [];
|
|
419
|
+
ruleFieldTd.append(ruleFieldSelect);
|
|
420
|
+
ruleFieldSelect.on("change", function () {
|
|
421
|
+
rule.field = $(ruleFieldSelect).val();
|
|
422
|
+
|
|
423
|
+
var trpar = $(this).parents("tr:first"), columns, k; // define LOCAL variables
|
|
424
|
+
for (k = 0; k < that.p.columns.length; k++) {
|
|
425
|
+
if (that.p.columns[k].name === rule.field) {
|
|
426
|
+
columns = that.p.columns[k];
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
if (!columns) { return; }
|
|
431
|
+
var editoptions = $.extend({}, columns.editoptions || {});
|
|
432
|
+
delete editoptions.readonly;
|
|
433
|
+
delete editoptions.disabled;
|
|
434
|
+
var searchoptions = $.extend(
|
|
435
|
+
{},
|
|
436
|
+
editoptions || {},
|
|
437
|
+
columns.searchoptions || {},
|
|
438
|
+
getCmInfo(columns.cmName),
|
|
439
|
+
{ id: jgrid.randId(), name: columns.name, mode: "search" }
|
|
440
|
+
);
|
|
441
|
+
searchoptions.column = columns; // add reference to that.p.columns[k];
|
|
442
|
+
if (isIE && columns.inputtype === "text") {
|
|
443
|
+
if (!searchoptions.size) {
|
|
444
|
+
searchoptions.size = 10;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
var elm = jgrid.createEl.call($t, columns.inputtype,
|
|
448
|
+
$.extend({}, searchoptions, searchoptions.attr || {}),
|
|
449
|
+
"", true, that.p.ajaxSelectOptions || {}, true);
|
|
450
|
+
$(elm).addClass(getGuiStyles("searchDialog.elem", "input-elm"));
|
|
451
|
+
//that.createElement(rule, "");
|
|
452
|
+
|
|
453
|
+
if (searchoptions.sopt) {
|
|
454
|
+
op = searchoptions.sopt;
|
|
455
|
+
} else if (that.p.sopt) {
|
|
456
|
+
op = that.p.sopt;
|
|
457
|
+
} else if ($.inArray(columns.searchtype, that.p.strarr) !== -1) {
|
|
458
|
+
op = that.p.stropts;
|
|
459
|
+
} else {
|
|
460
|
+
op = that.p.numopts;
|
|
461
|
+
}
|
|
462
|
+
// operators
|
|
463
|
+
var s = "", so = 0, odataItem1, itemOper1, itemText;
|
|
464
|
+
aoprs = [];
|
|
465
|
+
$.each(that.p.ops, function () { aoprs.push(this.oper); });
|
|
466
|
+
// append aoprs array with custom operations defined in customSortOperations parameter jqGrid
|
|
467
|
+
if (that.p.cops) {
|
|
468
|
+
$.each(that.p.cops, function (propertyName) { aoprs.push(propertyName); });
|
|
469
|
+
}
|
|
470
|
+
for (k = 0; k < op.length; k++) {
|
|
471
|
+
itemOper1 = op[k];
|
|
472
|
+
ina = $.inArray(op[k], aoprs);
|
|
473
|
+
if (ina !== -1) {
|
|
474
|
+
odataItem1 = that.p.ops[ina];
|
|
475
|
+
itemText = odataItem1 !== undefined ? odataItem1.text : that.p.cops[itemOper1].text;
|
|
476
|
+
if (so === 0) {
|
|
477
|
+
// the first select item will be automatically selected in single-select
|
|
478
|
+
rule.op = itemOper1;
|
|
479
|
+
}
|
|
480
|
+
s += "<option value='" + itemOper1 + "'>" + itemText + "</option>";
|
|
481
|
+
so++;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
$(".selectopts", trpar).empty().append(s);
|
|
485
|
+
$(".selectopts", trpar)[0].selectedIndex = 0;
|
|
486
|
+
if (jgrid.msie && jgrid.msiever() < 9) {
|
|
487
|
+
var sw = parseInt($("select.selectopts", trpar)[0].offsetWidth, 10) + 1;
|
|
488
|
+
$(".selectopts", trpar).width(sw);
|
|
489
|
+
$(".selectopts", trpar).css("width", "auto");
|
|
490
|
+
}
|
|
491
|
+
// data
|
|
492
|
+
$(".data", trpar).empty().append(elm);
|
|
493
|
+
if (columns.createColumnIndex && searchoptions.generateDatalist) {
|
|
494
|
+
var dataListId = "dl_" + elm.id,
|
|
495
|
+
$datalist = $($t).jqGrid("generateDatalistFromColumnIndex", columns.name);
|
|
496
|
+
if ($datalist != null && $datalist.length > 0) {
|
|
497
|
+
$(elm).attr("list", dataListId);
|
|
498
|
+
$(".data", trpar).append($datalist.attr("id", dataListId));
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
jgrid.bindEv.call($t, elm, searchoptions);
|
|
502
|
+
$(".input-elm", trpar).on("change", searchoptions, function (e) {
|
|
503
|
+
var elem = e.target, column = e.data.column;
|
|
504
|
+
rule.data = column && column.inputtype === "custom" && isFunction(column.searchoptions.custom_value) ?
|
|
505
|
+
column.searchoptions.custom_value.call($t, $(this).find(".customelement").first(), "get") :
|
|
506
|
+
elem.value;
|
|
507
|
+
if ($(elem).is("input[type=checkbox]") && !$(elem).is(":checked")) {
|
|
508
|
+
// value of checkbox contains checked value
|
|
509
|
+
rule.data = $(elem).data("offval");
|
|
510
|
+
}
|
|
511
|
+
that.onchange(); // signals that the filter has changed
|
|
512
|
+
});
|
|
513
|
+
setTimeout(function () { //IE, Opera, Chrome
|
|
514
|
+
rule.data = $(elm).val();
|
|
515
|
+
if (cm.inputtype === 'select' && cm.searchoptions.multiple && Array.isArray(rule.data)) {
|
|
516
|
+
rule.data = rule.data.join(",");
|
|
517
|
+
}
|
|
518
|
+
that.onchange(); // signals that the filter has changed
|
|
519
|
+
}, 0);
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
// populate drop down with user provided column definitions
|
|
523
|
+
var j = 0, searchable, hidden, ignoreHiding;
|
|
524
|
+
for (i = 0; i < that.p.columns.length; i++) {
|
|
525
|
+
// but show only serchable and serchhidden = true fields
|
|
526
|
+
searchable = (that.p.columns[i].search === undefined) ? true : that.p.columns[i].search;
|
|
527
|
+
hidden = (that.p.columns[i].hidden === true);
|
|
528
|
+
ignoreHiding = (that.p.columns[i].searchoptions.searchhidden === true);
|
|
529
|
+
if ((ignoreHiding && searchable) || (searchable && !hidden)) {
|
|
530
|
+
selected = "";
|
|
531
|
+
if (rule.field === that.p.columns[i].name) {
|
|
532
|
+
selected = " selected='selected'";
|
|
533
|
+
j = i;
|
|
534
|
+
}
|
|
535
|
+
str += "<option value='" + that.p.columns[i].name + "'" + selected + ">" + that.p.columns[i].label + "</option>";
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
ruleFieldSelect.append(str);
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
// create operator container
|
|
542
|
+
var ruleOperatorTd = $("<td class='operators'></td>");
|
|
543
|
+
tr.append(ruleOperatorTd);
|
|
544
|
+
cm = p.columns[j];
|
|
545
|
+
// create it here so it can be referentiated in the onchange event
|
|
546
|
+
//var RD = that.createElement(rule, rule.data);
|
|
547
|
+
if (isIE && cm.inputtype === "text") {
|
|
548
|
+
if (!cm.searchoptions.size) {
|
|
549
|
+
cm.searchoptions.size = 10;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
var editoptions = $.extend({}, cm.editoptions || {});
|
|
553
|
+
delete editoptions.readonly;
|
|
554
|
+
delete editoptions.disabled;
|
|
555
|
+
var searchoptions = $.extend(
|
|
556
|
+
{},
|
|
557
|
+
editoptions,
|
|
558
|
+
cm.searchoptions || {},
|
|
559
|
+
getCmInfo(cm.cmName),
|
|
560
|
+
{ id: jgrid.randId(), name: cm.name, mode: "search" });
|
|
561
|
+
searchoptions.column = cm;
|
|
562
|
+
var ruleDataInput = jgrid.createEl.call($t, cm.inputtype,
|
|
563
|
+
$.extend({}, searchoptions, searchoptions.attr || {}),
|
|
564
|
+
rule.data, true, that.p.ajaxSelectOptions || {}, true);
|
|
565
|
+
if (rule.op === "nu" || rule.op === "nn" || $.inArray(rule.op, $t.p.customUnaryOperations) >= 0) {
|
|
566
|
+
$(ruleDataInput).attr("readonly", "true");
|
|
567
|
+
$(ruleDataInput).attr("disabled", "true");
|
|
568
|
+
} //retain the state of disabled text fields in case of null ops
|
|
569
|
+
// dropdown for: choosing operator
|
|
570
|
+
var ruleOperatorSelect = $("<select class='" + getGuiStyles("searchDialog.operator", "selectopts") + "'></select>");
|
|
571
|
+
ruleOperatorTd.append(ruleOperatorSelect);
|
|
572
|
+
ruleOperatorSelect.on("change", function () {
|
|
573
|
+
rule.op = $(ruleOperatorSelect).val();
|
|
574
|
+
var trpar = $(this).parents("tr:first"),
|
|
575
|
+
rd = $(".input-elm", trpar)[0];
|
|
576
|
+
if (rule.op === "nu" || rule.op === "nn" || $.inArray(rule.op, $t.p.customUnaryOperations) >= 0) { // disable for operator "is null" and "is not null"
|
|
577
|
+
rule.data = "";
|
|
578
|
+
if (rd.tagName.toUpperCase() !== "SELECT") { rd.value = ""; }
|
|
579
|
+
rd.setAttribute("readonly", "true");
|
|
580
|
+
rd.setAttribute("disabled", "true");
|
|
581
|
+
} else {
|
|
582
|
+
if (rd.tagName.toUpperCase() === "SELECT") { rule.data = rd.value; }
|
|
583
|
+
rd.removeAttribute("readonly");
|
|
584
|
+
rd.removeAttribute("disabled");
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
that.onchange(); // signals that the filter has changed
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// populate drop down with all available operators
|
|
591
|
+
if (cm.searchoptions.sopt) {
|
|
592
|
+
op = cm.searchoptions.sopt;
|
|
593
|
+
} else if (that.p.sopt) {
|
|
594
|
+
op = that.p.sopt;
|
|
595
|
+
} else if ($.inArray(cm.searchtype, that.p.strarr) !== -1) {
|
|
596
|
+
op = that.p.stropts;
|
|
597
|
+
} else {
|
|
598
|
+
op = that.p.numopts;
|
|
599
|
+
}
|
|
600
|
+
str = "";
|
|
601
|
+
var odataItem, itemOper;
|
|
602
|
+
$.each(that.p.ops, function () { aoprs.push(this.oper); });
|
|
603
|
+
// append aoprs array with custom operations defined in customSortOperations parameter jqGrid
|
|
604
|
+
if (that.p.cops) {
|
|
605
|
+
$.each(that.p.cops, function (propertyName) { aoprs.push(propertyName); });
|
|
606
|
+
}
|
|
607
|
+
for (i = 0; i < op.length; i++) {
|
|
608
|
+
itemOper = op[i];
|
|
609
|
+
ina = $.inArray(op[i], aoprs);
|
|
610
|
+
if (ina !== -1) {
|
|
611
|
+
odataItem = that.p.ops[ina];
|
|
612
|
+
selected = rule.op === itemOper ? " selected='selected'" : "";
|
|
613
|
+
str += "<option value='" + itemOper + "'" + selected + ">" +
|
|
614
|
+
(odataItem !== undefined ? odataItem.text : that.p.cops[itemOper].text) +
|
|
615
|
+
"</option>";
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
ruleOperatorSelect.append(str);
|
|
619
|
+
// create data container
|
|
620
|
+
var ruleDataTd = $("<td class='data'></td>");
|
|
621
|
+
tr.append(ruleDataTd);
|
|
622
|
+
|
|
623
|
+
// textbox for: data
|
|
624
|
+
// is created previously
|
|
625
|
+
//ruleDataInput.setAttribute("type", "text");
|
|
626
|
+
ruleDataTd.append(ruleDataInput);
|
|
627
|
+
if (cm.createColumnIndex && cm.searchoptions.generateDatalist) {
|
|
628
|
+
var dataListId = "dl_" + ruleDataInput.id,
|
|
629
|
+
$datalist = $($t).jqGrid("generateDatalistFromColumnIndex", cm.name);
|
|
630
|
+
if ($datalist != null && $datalist.length > 0) {
|
|
631
|
+
$(ruleDataInput).attr("list", dataListId);
|
|
632
|
+
ruleDataTd.append($datalist.attr("id", dataListId));
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
jgrid.bindEv.call($t, ruleDataInput, cm.searchoptions);
|
|
636
|
+
$(ruleDataInput).addClass(getGuiStyles("searchDialog.elem", "input-elm"))
|
|
637
|
+
.on("change", function () {
|
|
638
|
+
rule.data = cm.inputtype === "custom" ?
|
|
639
|
+
cm.searchoptions.custom_value.call($t, $(this).find(".customelement").first(), "get") :
|
|
640
|
+
$(this).val();
|
|
641
|
+
if ($(this).is("input[type=checkbox]") && !$(this).is(":checked")) {
|
|
642
|
+
// value of checkbox contains checked value
|
|
643
|
+
rule.data = $(this).data("offval");
|
|
644
|
+
}
|
|
645
|
+
if (Array.isArray(rule.data)) {
|
|
646
|
+
rule.data = rule.data.join(p.inFilterSeparator || ",");
|
|
647
|
+
}
|
|
648
|
+
that.onchange(); // signals that the filter has changed
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
// create action container
|
|
652
|
+
var ruleDeleteTd = $("<td></td>");
|
|
653
|
+
tr.append(ruleDeleteTd);
|
|
654
|
+
|
|
655
|
+
// create button for: delete rule
|
|
656
|
+
if (p.ruleButtons === true) {
|
|
657
|
+
var ruleDeleteInput = $("<input type='button' value='-' title='" + getRes("deleteRuleTitle") + "' class='" +
|
|
658
|
+
getGuiStyles("searchDialog.deleteRuleButton", "delete-rule ui-del") + "'/>");
|
|
659
|
+
ruleDeleteTd.append(ruleDeleteInput);
|
|
660
|
+
//$(ruleDeleteInput).html("").height(20).width(30).button({icons: { primary: "ui-icon-minus", text:false}});
|
|
661
|
+
ruleDeleteInput.on("click", function () {
|
|
662
|
+
// remove rule from group
|
|
663
|
+
for (i = 0; i < group.rules.length; i++) {
|
|
664
|
+
if (group.rules[i] === rule) {
|
|
665
|
+
group.rules.splice(i, 1);
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
that.reDraw(); // the html has changed, force reDraw
|
|
671
|
+
|
|
672
|
+
that.onchange(); // signals that the filter has changed
|
|
673
|
+
return false;
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
return tr;
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
this.getStringForGroup = function (group) {
|
|
680
|
+
var s = "(", index;
|
|
681
|
+
if (group.groups !== undefined) {
|
|
682
|
+
for (index = 0; index < group.groups.length; index++) {
|
|
683
|
+
if (s.length > 1) {
|
|
684
|
+
s += " " + group.groupOp + " ";
|
|
685
|
+
}
|
|
686
|
+
try {
|
|
687
|
+
s += this.getStringForGroup(group.groups[index]);
|
|
688
|
+
} catch (eg) {
|
|
689
|
+
fatalErrorFunction(eg);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
if (group.rules !== undefined) {
|
|
695
|
+
try {
|
|
696
|
+
for (index = 0; index < group.rules.length; index++) {
|
|
697
|
+
if (s.length > 1) {
|
|
698
|
+
s += " " + group.groupOp + " ";
|
|
699
|
+
}
|
|
700
|
+
s += this.getStringForRule(group.rules[index]);
|
|
701
|
+
}
|
|
702
|
+
} catch (e) {
|
|
703
|
+
fatalErrorFunction(e);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
s += ")";
|
|
708
|
+
|
|
709
|
+
if (s === "()") {
|
|
710
|
+
return ""; // ignore groups that don't have rules
|
|
711
|
+
}
|
|
712
|
+
return s;
|
|
713
|
+
};
|
|
714
|
+
this.getStringForRule = function (rule) {
|
|
715
|
+
var operand = "", opC = "", i, cm, ret, val = rule.data, oper, numtypes = ["int", "integer", "float", "number", "currency"]; // jqGrid
|
|
716
|
+
for (i = 0; i < p.ops.length; i++) {
|
|
717
|
+
if (p.ops[i].oper === rule.op) {
|
|
718
|
+
operand = p.operands.hasOwnProperty(rule.op) ? p.operands[rule.op] : "";
|
|
719
|
+
opC = p.ops[i].oper;
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
if (opC === "" && p.cops != null) {
|
|
724
|
+
for (oper in p.cops) {
|
|
725
|
+
if (p.cops.hasOwnProperty(oper)) {
|
|
726
|
+
opC = oper;
|
|
727
|
+
operand = p.cops[oper].operand;
|
|
728
|
+
if (isFunction(p.cops[oper].buildQueryValue)) {
|
|
729
|
+
return p.cops[oper].buildQueryValue.call(p, { cmName: rule.field, searchValue: val, operand: operand });
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
for (i = 0; i < p.columns.length; i++) {
|
|
735
|
+
if (p.columns[i].name === rule.field) {
|
|
736
|
+
cm = p.columns[i];
|
|
737
|
+
break;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
if (cm == null) {
|
|
741
|
+
return "";
|
|
742
|
+
}
|
|
743
|
+
if (opC === "bw" || opC === "bn") {
|
|
744
|
+
val = val + "%";
|
|
745
|
+
}
|
|
746
|
+
if (opC === "ew" || opC === "en") {
|
|
747
|
+
val = "%" + val;
|
|
748
|
+
}
|
|
749
|
+
if (opC === "cn" || opC === "nc") {
|
|
750
|
+
val = "%" + val + "%";
|
|
751
|
+
}
|
|
752
|
+
if (opC === "in" || opC === "ni") {
|
|
753
|
+
val = " (" + val + ")";
|
|
754
|
+
}
|
|
755
|
+
if (p.errorcheck) {
|
|
756
|
+
checkData(rule.data, cm);
|
|
757
|
+
}
|
|
758
|
+
if ($.inArray(cm.searchtype, numtypes) !== -1 || opC === "nn" || opC === "nu" || $.inArray(opC, getGrid().p.customUnaryOperations) >= 0) {
|
|
759
|
+
ret = rule.field + " " + operand + " " + val;
|
|
760
|
+
} else {
|
|
761
|
+
ret = rule.field + " " + operand + ' "' + val + '"';
|
|
762
|
+
}
|
|
763
|
+
return ret;
|
|
764
|
+
};
|
|
765
|
+
this.resetFilter = function () {
|
|
766
|
+
p.filter = $.extend(true, {}, p.initFilter);
|
|
767
|
+
this.reDraw();
|
|
768
|
+
this.onchange();
|
|
769
|
+
};
|
|
770
|
+
this.hideError = function () {
|
|
771
|
+
$("th." + errorClass, this).html("");
|
|
772
|
+
$("tr.error", this).hide();
|
|
773
|
+
};
|
|
774
|
+
this.showError = function () {
|
|
775
|
+
$("th." + errorClass, this).html(p.errmsg);
|
|
776
|
+
$("tr.error", this).show();
|
|
777
|
+
};
|
|
778
|
+
this.toUserFriendlyString = function () {
|
|
779
|
+
return this.getStringForGroup(p.filter);
|
|
780
|
+
};
|
|
781
|
+
this.toString = function () {
|
|
782
|
+
// this will obtain a string that can be used to match an item.
|
|
783
|
+
var that = this;
|
|
784
|
+
function getStringRule(rule) {
|
|
785
|
+
if (that.p.errorcheck) {
|
|
786
|
+
var i, cm;
|
|
787
|
+
for (i = 0; i < that.p.columns.length; i++) {
|
|
788
|
+
if (that.p.columns[i].name === rule.field) {
|
|
789
|
+
cm = that.p.columns[i];
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
if (cm) {
|
|
794
|
+
checkData(rule.data, cm);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return rule.op + "(item." + rule.field + ",'" + rule.data + "')";
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
function getStringForGroup(group) {
|
|
801
|
+
var s = "(", index;
|
|
802
|
+
|
|
803
|
+
if (group.groups !== undefined) {
|
|
804
|
+
for (index = 0; index < group.groups.length; index++) {
|
|
805
|
+
if (s.length > 1) {
|
|
806
|
+
if (group.groupOp === "OR") {
|
|
807
|
+
s += " || ";
|
|
808
|
+
} else {
|
|
809
|
+
s += " && ";
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
s += getStringForGroup(group.groups[index]);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
if (group.rules !== undefined) {
|
|
817
|
+
for (index = 0; index < group.rules.length; index++) {
|
|
818
|
+
if (s.length > 1) {
|
|
819
|
+
if (group.groupOp === "OR") {
|
|
820
|
+
s += " || ";
|
|
821
|
+
} else {
|
|
822
|
+
s += " && ";
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
s += getStringRule(group.rules[index]);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
s += ")";
|
|
830
|
+
|
|
831
|
+
if (s === "()") {
|
|
832
|
+
return ""; // ignore groups that don't have rules
|
|
833
|
+
}
|
|
834
|
+
return s;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
return getStringForGroup(p.filter);
|
|
838
|
+
};
|
|
839
|
+
|
|
840
|
+
// Here we init the filter
|
|
841
|
+
this.reDraw();
|
|
842
|
+
|
|
843
|
+
if (p.showQuery) {
|
|
844
|
+
this.onchange();
|
|
845
|
+
}
|
|
846
|
+
// mark is as created so that it will not be created twice on this element
|
|
847
|
+
this.filter = true;
|
|
848
|
+
});
|
|
849
|
+
};
|
|
850
|
+
$.extend($.fn.jqFilter, {
|
|
851
|
+
/*
|
|
852
|
+
* Return SQL like string. Can be used directly
|
|
853
|
+
*/
|
|
854
|
+
toSQLString: function () {
|
|
855
|
+
var s = "";
|
|
856
|
+
this.each(function () {
|
|
857
|
+
s = this.toUserFriendlyString();
|
|
858
|
+
});
|
|
859
|
+
return s;
|
|
860
|
+
},
|
|
861
|
+
/*
|
|
862
|
+
* Return filter data as object.
|
|
863
|
+
*/
|
|
864
|
+
filterData: function () {
|
|
865
|
+
var s;
|
|
866
|
+
this.each(function () {
|
|
867
|
+
s = this.p.filter;
|
|
868
|
+
});
|
|
869
|
+
return s;
|
|
870
|
+
|
|
871
|
+
},
|
|
872
|
+
getParameter: function (param) {
|
|
873
|
+
if (param !== undefined) {
|
|
874
|
+
if (this.p.hasOwnProperty(param)) {
|
|
875
|
+
return this.p[param];
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return this.p;
|
|
879
|
+
},
|
|
880
|
+
resetFilter: function () {
|
|
881
|
+
return this.each(function () {
|
|
882
|
+
this.resetFilter();
|
|
883
|
+
});
|
|
884
|
+
},
|
|
885
|
+
addFilter: function (pfilter) {
|
|
886
|
+
if (typeof pfilter === "string") {
|
|
887
|
+
pfilter = JSON.parse(pfilter);
|
|
888
|
+
}
|
|
889
|
+
this.each(function () {
|
|
890
|
+
this.p.filter = pfilter;
|
|
891
|
+
this.reDraw();
|
|
892
|
+
this.onchange();
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
// end module grid.filter
|
|
897
|
+
}));
|