rails_jq_grid 0.0.3.pre2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/public/javascripts/rails-jqgrid/Changes.txt +0 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg.js +132 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg1251.js +132 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cat.js +128 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cn.js +132 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cs.js +128 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-da.js +128 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-de.js +133 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-el.js +126 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-en.js +128 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-es.js +128 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fa.js +145 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fi.js +130 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fr.js +126 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-gl.js +126 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-he.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-hu.js +129 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-is.js +126 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-it.js +1 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ja.js +155 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-nl.js +149 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-no.js +1 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pl.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt-br.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt.js +125 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ro.js +139 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ru.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-sk.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-sr.js +128 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-sv.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-tr.js +126 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ua.js +127 -1
- data/public/javascripts/rails-jqgrid/install.txt +0 -0
- data/public/javascripts/rails-jqgrid/jquery.jqGrid.min.js +445 -432
- data/public/javascripts/rails-jqgrid/src/JsonXml.js +329 -329
- data/public/javascripts/rails-jqgrid/src/css/ellipsis-xbl.xml +0 -0
- data/public/javascripts/rails-jqgrid/src/css/ui.jqgrid.css +139 -129
- data/public/javascripts/rails-jqgrid/src/css/ui.multiselect.css +0 -0
- data/public/javascripts/rails-jqgrid/src/grid.base.js +3078 -3003
- data/public/javascripts/rails-jqgrid/src/grid.celledit.js +486 -486
- data/public/javascripts/rails-jqgrid/src/grid.common.js +646 -636
- data/public/javascripts/rails-jqgrid/src/grid.custom.js +820 -817
- data/public/javascripts/rails-jqgrid/src/grid.formedit.js +1954 -1872
- data/public/javascripts/rails-jqgrid/src/grid.grouping.js +250 -0
- data/public/javascripts/rails-jqgrid/src/grid.import.js +200 -200
- data/public/javascripts/rails-jqgrid/src/grid.inlinedit.js +255 -250
- data/public/javascripts/rails-jqgrid/src/grid.jqueryui.js +504 -503
- data/public/javascripts/rails-jqgrid/src/grid.loader.js +1 -0
- data/public/javascripts/rails-jqgrid/src/grid.postext.js +63 -63
- data/public/javascripts/rails-jqgrid/src/grid.setcolumns.js +125 -125
- data/public/javascripts/rails-jqgrid/src/grid.subgrid.js +260 -260
- data/public/javascripts/rails-jqgrid/src/grid.tbltogrid.js +106 -106
- data/public/javascripts/rails-jqgrid/src/grid.treegrid.js +489 -482
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg.js +132 -132
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg1251.js +132 -132
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cat.js +128 -128
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cn.js +132 -132
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cs.js +128 -128
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-da.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-de.js +132 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-dk.js +0 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-el.js +126 -126
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-en.js +128 -128
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-es.js +128 -128
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fa.js +145 -125
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fi.js +130 -130
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fr.js +2 -2
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-gl.js +126 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-he.js +127 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-hu.js +129 -129
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-is.js +126 -126
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-it.js +0 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ja.js +155 -155
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-nl.js +148 -148
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-no.js +0 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pl.js +126 -126
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt-br.js +127 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt.js +125 -125
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ro.js +139 -139
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ru.js +127 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sk.js +127 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sr.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sv.js +127 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-tr.js +126 -126
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ua.js +127 -127
- data/public/javascripts/rails-jqgrid/src/jqDnR.js +68 -67
- data/public/javascripts/rails-jqgrid/src/jqModal.js +68 -68
- data/public/javascripts/rails-jqgrid/src/jquery.fmatter.js +563 -541
- data/public/javascripts/rails-jqgrid/src/jquery.searchFilter.js +1 -1
- data/public/javascripts/rails-jqgrid/src/ui.multiselect.js +0 -0
- data/public/stylesheets/rails-jqgrid/ellipsis-xbl.xml +0 -0
- data/public/stylesheets/rails-jqgrid/ui.jqgrid.css +139 -2
- data/rails_jq_grid.gemspec +10 -3
- metadata +15 -11
@@ -1,818 +1,821 @@
|
|
1
|
-
;(function($){
|
2
|
-
/**
|
3
|
-
* jqGrid extension for custom methods
|
4
|
-
* Tony Tomov tony@trirand.com
|
5
|
-
* http://trirand.com/blog/
|
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
|
-
$.jgrid.extend({
|
11
|
-
getColProp : function(colname){
|
12
|
-
var ret ={}, $t = this[0];
|
13
|
-
if ( !$t.grid ) { return; }
|
14
|
-
var cM = $t.p.colModel;
|
15
|
-
for ( var i =0;i<cM.length;i++ ) {
|
16
|
-
if ( cM[i].name == colname ) {
|
17
|
-
ret = cM[i];
|
18
|
-
break;
|
19
|
-
}
|
20
|
-
}
|
21
|
-
return ret;
|
22
|
-
},
|
23
|
-
setColProp : function(colname, obj){
|
24
|
-
//do not set width will not work
|
25
|
-
return this.each(function(){
|
26
|
-
if ( this.grid ) {
|
27
|
-
if ( obj ) {
|
28
|
-
var cM = this.p.colModel;
|
29
|
-
for ( var i =0;i<cM.length;i++ ) {
|
30
|
-
if ( cM[i].name == colname ) {
|
31
|
-
$.extend(this.p.colModel[i],obj);
|
32
|
-
break;
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}
|
37
|
-
});
|
38
|
-
},
|
39
|
-
sortGrid : function(colname,reload, sor){
|
40
|
-
return this.each(function(){
|
41
|
-
var $t=this,idx=-1;
|
42
|
-
if ( !$t.grid ) { return;}
|
43
|
-
if ( !colname ) { colname = $t.p.sortname; }
|
44
|
-
for ( var i=0;i<$t.p.colModel.length;i++ ) {
|
45
|
-
if ( $t.p.colModel[i].index == colname || $t.p.colModel[i].name==colname ) {
|
46
|
-
idx = i;
|
47
|
-
break;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
if ( idx!=-1 ){
|
51
|
-
var sort = $t.p.colModel[idx].sortable;
|
52
|
-
if ( typeof sort !== 'boolean' ) { sort = true; }
|
53
|
-
if ( typeof reload !=='boolean' ) { reload = false; }
|
54
|
-
if ( sort ) { $t.sortData("jqgh_"+colname, idx, reload, sor); }
|
55
|
-
}
|
56
|
-
});
|
57
|
-
},
|
58
|
-
GridDestroy : function () {
|
59
|
-
return this.each(function(){
|
60
|
-
if ( this.grid ) {
|
61
|
-
if ( this.p.pager ) { // if not part of grid
|
62
|
-
$(this.p.pager).remove();
|
63
|
-
}
|
64
|
-
var gid = this.id;
|
65
|
-
try {
|
66
|
-
$("#gbox_"+gid).remove();
|
67
|
-
} catch (_) {}
|
68
|
-
}
|
69
|
-
});
|
70
|
-
},
|
71
|
-
GridUnload : function(){
|
72
|
-
return this.each(function(){
|
73
|
-
if ( !this.grid ) {return;}
|
74
|
-
var defgrid = {id: $(this).attr('id'),cl: $(this).attr('class')};
|
75
|
-
if (this.p.pager) {
|
76
|
-
$(this.p.pager).empty().removeClass("ui-state-default ui-jqgrid-pager corner-bottom");
|
77
|
-
}
|
78
|
-
var newtable = document.createElement('table');
|
79
|
-
$(newtable).attr({id:defgrid.id});
|
80
|
-
newtable.className = defgrid.cl;
|
81
|
-
var gid = this.id;
|
82
|
-
$(newtable).removeClass("ui-jqgrid-btable");
|
83
|
-
if( $(this.p.pager).parents("#gbox_"+gid).length === 1 ) {
|
84
|
-
$(newtable).insertBefore("#gbox_"+gid).show();
|
85
|
-
$(this.p.pager).insertBefore("#gbox_"+gid);
|
86
|
-
} else {
|
87
|
-
$(newtable).insertBefore("#gbox_"+gid).show();
|
88
|
-
}
|
89
|
-
$("#gbox_"+gid).remove();
|
90
|
-
});
|
91
|
-
},
|
92
|
-
setGridState : function(state) {
|
93
|
-
return this.each(function(){
|
94
|
-
if ( !this.grid ) {return;}
|
95
|
-
var $t = this;
|
96
|
-
if(state == 'hidden'){
|
97
|
-
$(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv","#gview_"+$t.p.id).slideUp("fast");
|
98
|
-
if($t.p.pager) {$($t.p.pager).slideUp("fast");}
|
99
|
-
if($t.p.toppager) {$($t.p.toppager).slideUp("fast");}
|
100
|
-
if($t.p.toolbar[0]===true) {
|
101
|
-
if( $t.p.toolbar[1]=='both') {
|
102
|
-
$($t.grid.ubDiv).slideUp("fast");
|
103
|
-
}
|
104
|
-
$($t.grid.uDiv).slideUp("fast");
|
105
|
-
}
|
106
|
-
if($t.p.footerrow) { $(".ui-jqgrid-sdiv","#gbox_"+$t.p.id).slideUp("fast"); }
|
107
|
-
$(".ui-jqgrid-titlebar-close span",$t.grid.cDiv).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s");
|
108
|
-
$t.p.gridstate = 'hidden';
|
109
|
-
} else if(state=='visible') {
|
110
|
-
$(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv","#gview_"+$t.p.id).slideDown("fast");
|
111
|
-
if($t.p.pager) {$($t.p.pager).slideDown("fast");}
|
112
|
-
if($t.p.toppager) {$($t.p.toppager).slideDown("fast");}
|
113
|
-
if($t.p.toolbar[0]===true) {
|
114
|
-
if( $t.p.toolbar[1]=='both') {
|
115
|
-
$($t.grid.ubDiv).slideDown("fast");
|
116
|
-
}
|
117
|
-
$($t.grid.uDiv).slideDown("fast");
|
118
|
-
}
|
119
|
-
if($t.p.footerrow) { $(".ui-jqgrid-sdiv","#gbox_"+$t.p.id).slideDown("fast"); }
|
120
|
-
$(".ui-jqgrid-titlebar-close span",$t.grid.cDiv).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n");
|
121
|
-
$t.p.gridstate = 'visible';
|
122
|
-
}
|
123
|
-
|
124
|
-
});
|
125
|
-
},
|
126
|
-
updateGridRows : function (data, rowidname, jsonreader) {
|
127
|
-
var nm, success=false, title;
|
128
|
-
this.each(function(){
|
129
|
-
var t = this, vl, ind, srow, sid;
|
130
|
-
if(!t.grid) {return false;}
|
131
|
-
if(!rowidname) { rowidname = "id"; }
|
132
|
-
if( data && data.length >0 ) {
|
133
|
-
$(data).each(function(j){
|
134
|
-
srow = this;
|
135
|
-
ind = t.rows.namedItem(srow[rowidname]);
|
136
|
-
if(ind) {
|
137
|
-
sid = srow[rowidname];
|
138
|
-
if(jsonreader === true){
|
139
|
-
if(t.p.jsonReader.repeatitems === true) {
|
140
|
-
if(t.p.jsonReader.cell) {srow = srow[t.p.jsonReader.cell];}
|
141
|
-
for (var k=0;k<srow.length;k++) {
|
142
|
-
vl = t.formatter( sid, srow[k], k, srow, 'edit');
|
143
|
-
title = t.p.colModel[k].title ? {"title":$.jgrid.stripHtml(vl)} : {};
|
144
|
-
if(t.p.treeGrid===true && nm == t.p.ExpandColumn) {
|
145
|
-
$("td:eq("+k+") > span:first",ind).html(vl).attr(title);
|
146
|
-
} else {
|
147
|
-
$("td:eq("+k+")",ind).html(vl).attr(title);
|
148
|
-
}
|
149
|
-
}
|
150
|
-
success = true;
|
151
|
-
return true;
|
152
|
-
}
|
153
|
-
}
|
154
|
-
$(t.p.colModel).each(function(i){
|
155
|
-
nm = jsonreader===true ? this.jsonmap || this.name :this.name;
|
156
|
-
if( srow[nm] !== undefined) {
|
157
|
-
vl = t.formatter( sid, srow[nm], i, srow, 'edit');
|
158
|
-
title = this.title ? {"title":$.jgrid.stripHtml(vl)} : {};
|
159
|
-
if(t.p.treeGrid===true && nm == t.p.ExpandColumn) {
|
160
|
-
$("td:eq("+i+") > span:first",ind).html(vl).attr(title);
|
161
|
-
} else {
|
162
|
-
$("td:eq("+i+")",ind).html(vl).attr(title);
|
163
|
-
}
|
164
|
-
success = true;
|
165
|
-
}
|
166
|
-
});
|
167
|
-
}
|
168
|
-
});
|
169
|
-
}
|
170
|
-
});
|
171
|
-
return success;
|
172
|
-
},
|
173
|
-
filterGrid : function(gridid,p){
|
174
|
-
p = $.extend({
|
175
|
-
gridModel : false,
|
176
|
-
gridNames : false,
|
177
|
-
gridToolbar : false,
|
178
|
-
filterModel: [], // label/name/stype/defval/surl/sopt
|
179
|
-
formtype : "horizontal", // horizontal/vertical
|
180
|
-
autosearch: true, // if set to false a serch button should be enabled.
|
181
|
-
formclass: "filterform",
|
182
|
-
tableclass: "filtertable",
|
183
|
-
buttonclass: "filterbutton",
|
184
|
-
searchButton: "Search",
|
185
|
-
clearButton: "Clear",
|
186
|
-
enableSearch : false,
|
187
|
-
enableClear: false,
|
188
|
-
beforeSearch: null,
|
189
|
-
afterSearch: null,
|
190
|
-
beforeClear: null,
|
191
|
-
afterClear: null,
|
192
|
-
url : '',
|
193
|
-
marksearched: true
|
194
|
-
},p || {});
|
195
|
-
return this.each(function(){
|
196
|
-
var self = this;
|
197
|
-
this.p = p;
|
198
|
-
if(this.p.filterModel.length === 0 && this.p.gridModel===false) { alert("No filter is set"); return;}
|
199
|
-
if( !gridid) {alert("No target grid is set!"); return;}
|
200
|
-
this.p.gridid = gridid.indexOf("#") != -1 ? gridid : "#"+gridid;
|
201
|
-
var gcolMod = $(this.p.gridid).jqGrid("getGridParam",'colModel');
|
202
|
-
if(gcolMod) {
|
203
|
-
if( this.p.gridModel === true) {
|
204
|
-
var thegrid = $(this.p.gridid)[0];
|
205
|
-
var sh;
|
206
|
-
// we should use the options search, edittype, editoptions
|
207
|
-
// additionally surl and defval can be added in grid colModel
|
208
|
-
$.each(gcolMod, function (i,n) {
|
209
|
-
var tmpFil = [];
|
210
|
-
this.search = this.search === false ? false : true;
|
211
|
-
if(this.editrules && this.editrules.searchhidden === true) {
|
212
|
-
sh = true;
|
213
|
-
} else {
|
214
|
-
if(this.hidden === true ) {
|
215
|
-
sh = false;
|
216
|
-
} else {
|
217
|
-
sh = true;
|
218
|
-
}
|
219
|
-
}
|
220
|
-
if( this.search === true && sh === true) {
|
221
|
-
if(self.p.gridNames===true) {
|
222
|
-
tmpFil.label = thegrid.p.colNames[i];
|
223
|
-
} else {
|
224
|
-
tmpFil.label = '';
|
225
|
-
}
|
226
|
-
tmpFil.name = this.name;
|
227
|
-
tmpFil.index = this.index || this.name;
|
228
|
-
// we support only text and selects, so all other to text
|
229
|
-
tmpFil.stype = this.edittype || 'text';
|
230
|
-
if(tmpFil.stype != 'select' ) {
|
231
|
-
tmpFil.stype = 'text';
|
232
|
-
}
|
233
|
-
tmpFil.defval = this.defval || '';
|
234
|
-
tmpFil.surl = this.surl || '';
|
235
|
-
tmpFil.sopt = this.editoptions || {};
|
236
|
-
tmpFil.width = this.width;
|
237
|
-
self.p.filterModel.push(tmpFil);
|
238
|
-
}
|
239
|
-
});
|
240
|
-
} else {
|
241
|
-
$.each(self.p.filterModel,function(i,n) {
|
242
|
-
for(var j=0;j<gcolMod.length;j++) {
|
243
|
-
if(this.name == gcolMod[j].name) {
|
244
|
-
this.index = gcolMod[j].index || this.name;
|
245
|
-
break;
|
246
|
-
}
|
247
|
-
}
|
248
|
-
if(!this.index) {
|
249
|
-
this.index = this.name;
|
250
|
-
}
|
251
|
-
});
|
252
|
-
}
|
253
|
-
} else {
|
254
|
-
alert("Could not get grid colModel"); return;
|
255
|
-
}
|
256
|
-
var triggerSearch = function() {
|
257
|
-
var sdata={}, j=0, v;
|
258
|
-
var gr = $(self.p.gridid)[0], nm;
|
259
|
-
gr.p.searchdata = {};
|
260
|
-
if($.isFunction(self.p.beforeSearch)){self.p.beforeSearch();}
|
261
|
-
$.each(self.p.filterModel,function(i,n){
|
262
|
-
nm = this.index;
|
263
|
-
switch (this.stype) {
|
264
|
-
case 'select' :
|
265
|
-
v = $("select[name="+nm+"]",self).val();
|
266
|
-
if(v) {
|
267
|
-
sdata[nm] = v;
|
268
|
-
if(self.p.marksearched){
|
269
|
-
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
|
270
|
-
}
|
271
|
-
j++;
|
272
|
-
} else {
|
273
|
-
if(self.p.marksearched){
|
274
|
-
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
|
275
|
-
}
|
276
|
-
try {
|
277
|
-
delete gr.p.postData[this.index];
|
278
|
-
} catch (e) {}
|
279
|
-
}
|
280
|
-
break;
|
281
|
-
default:
|
282
|
-
v = $("input[name="+nm+"]",self).val();
|
283
|
-
if(v) {
|
284
|
-
sdata[nm] = v;
|
285
|
-
if(self.p.marksearched){
|
286
|
-
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
|
287
|
-
}
|
288
|
-
j++;
|
289
|
-
} else {
|
290
|
-
if(self.p.marksearched){
|
291
|
-
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
|
292
|
-
}
|
293
|
-
try {
|
294
|
-
delete gr.p.postData[this.index];
|
295
|
-
} catch(e) {}
|
296
|
-
}
|
297
|
-
}
|
298
|
-
});
|
299
|
-
var sd = j>0 ? true : false;
|
300
|
-
$.extend(gr.p.postData,sdata);
|
301
|
-
var saveurl;
|
302
|
-
if(self.p.url) {
|
303
|
-
saveurl = $(gr).jqGrid("getGridParam",'url');
|
304
|
-
$(gr).jqGrid("setGridParam",{url:self.p.url});
|
305
|
-
}
|
306
|
-
$(gr).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]);
|
307
|
-
if(saveurl) {$(gr).jqGrid("setGridParam",{url:saveurl});}
|
308
|
-
if($.isFunction(self.p.afterSearch)){self.p.afterSearch();}
|
309
|
-
};
|
310
|
-
var clearSearch = function(){
|
311
|
-
var sdata={}, v, j=0;
|
312
|
-
var gr = $(self.p.gridid)[0], nm;
|
313
|
-
if($.isFunction(self.p.beforeClear)){self.p.beforeClear();}
|
314
|
-
$.each(self.p.filterModel,function(i,n){
|
315
|
-
nm = this.index;
|
316
|
-
v = (this.defval) ? this.defval : "";
|
317
|
-
if(!this.stype){this.stype='text';}
|
318
|
-
switch (this.stype) {
|
319
|
-
case 'select' :
|
320
|
-
var v1;
|
321
|
-
$("select[name="+nm+"] option",self).each(function (i){
|
322
|
-
if(i===0) { this.selected = true; }
|
323
|
-
if ($(this).text() == v) {
|
324
|
-
this.selected = true;
|
325
|
-
v1 = $(this).val();
|
326
|
-
return false;
|
327
|
-
}
|
328
|
-
});
|
329
|
-
if(v1) {
|
330
|
-
// post the key and not the text
|
331
|
-
sdata[nm] = v1;
|
332
|
-
if(self.p.marksearched){
|
333
|
-
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
|
334
|
-
}
|
335
|
-
j++;
|
336
|
-
} else {
|
337
|
-
if(self.p.marksearched){
|
338
|
-
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
|
339
|
-
}
|
340
|
-
try {
|
341
|
-
delete gr.p.postData[this.index];
|
342
|
-
} catch (e) {}
|
343
|
-
}
|
344
|
-
break;
|
345
|
-
case 'text':
|
346
|
-
$("input[name="+nm+"]",self).val(v);
|
347
|
-
if(v) {
|
348
|
-
sdata[nm] = v;
|
349
|
-
if(self.p.marksearched){
|
350
|
-
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
|
351
|
-
}
|
352
|
-
j++;
|
353
|
-
} else {
|
354
|
-
if(self.p.marksearched){
|
355
|
-
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
|
356
|
-
}
|
357
|
-
try {
|
358
|
-
delete gr.p.postData[this.index];
|
359
|
-
} catch (e) {}
|
360
|
-
}
|
361
|
-
break;
|
362
|
-
}
|
363
|
-
});
|
364
|
-
var sd = j>0 ? true : false;
|
365
|
-
$.extend(gr.p.postData,sdata);
|
366
|
-
var saveurl;
|
367
|
-
if(self.p.url) {
|
368
|
-
saveurl = $(gr).jqGrid("getGridParam",'url');
|
369
|
-
$(gr).jqGrid("setGridParam",{url:self.p.url});
|
370
|
-
}
|
371
|
-
$(gr).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]);
|
372
|
-
if(saveurl) {$(gr).jqGrid("setGridParam",{url:saveurl});}
|
373
|
-
if($.isFunction(self.p.afterClear)){self.p.afterClear();}
|
374
|
-
};
|
375
|
-
var
|
376
|
-
|
377
|
-
var
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
$("select",this).
|
395
|
-
|
396
|
-
if(
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
var
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
ov
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
ov
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
if(
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
$(
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
$(
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
$(
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
$(
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
var
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
this.
|
515
|
-
this.
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
if($.isFunction(p.
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
$("select",self).
|
713
|
-
|
714
|
-
if(soptions.
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
if
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
var
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
if(soptions.
|
758
|
-
$(
|
759
|
-
if(
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
if(
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
case
|
792
|
-
|
793
|
-
case
|
794
|
-
case
|
795
|
-
case
|
796
|
-
case
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
1
|
+
;(function($){
|
2
|
+
/**
|
3
|
+
* jqGrid extension for custom methods
|
4
|
+
* Tony Tomov tony@trirand.com
|
5
|
+
* http://trirand.com/blog/
|
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
|
+
$.jgrid.extend({
|
11
|
+
getColProp : function(colname){
|
12
|
+
var ret ={}, $t = this[0];
|
13
|
+
if ( !$t.grid ) { return false; }
|
14
|
+
var cM = $t.p.colModel;
|
15
|
+
for ( var i =0;i<cM.length;i++ ) {
|
16
|
+
if ( cM[i].name == colname ) {
|
17
|
+
ret = cM[i];
|
18
|
+
break;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
return ret;
|
22
|
+
},
|
23
|
+
setColProp : function(colname, obj){
|
24
|
+
//do not set width will not work
|
25
|
+
return this.each(function(){
|
26
|
+
if ( this.grid ) {
|
27
|
+
if ( obj ) {
|
28
|
+
var cM = this.p.colModel;
|
29
|
+
for ( var i =0;i<cM.length;i++ ) {
|
30
|
+
if ( cM[i].name == colname ) {
|
31
|
+
$.extend(this.p.colModel[i],obj);
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
});
|
38
|
+
},
|
39
|
+
sortGrid : function(colname,reload, sor){
|
40
|
+
return this.each(function(){
|
41
|
+
var $t=this,idx=-1;
|
42
|
+
if ( !$t.grid ) { return;}
|
43
|
+
if ( !colname ) { colname = $t.p.sortname; }
|
44
|
+
for ( var i=0;i<$t.p.colModel.length;i++ ) {
|
45
|
+
if ( $t.p.colModel[i].index == colname || $t.p.colModel[i].name==colname ) {
|
46
|
+
idx = i;
|
47
|
+
break;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
if ( idx!=-1 ){
|
51
|
+
var sort = $t.p.colModel[idx].sortable;
|
52
|
+
if ( typeof sort !== 'boolean' ) { sort = true; }
|
53
|
+
if ( typeof reload !=='boolean' ) { reload = false; }
|
54
|
+
if ( sort ) { $t.sortData("jqgh_"+colname, idx, reload, sor); }
|
55
|
+
}
|
56
|
+
});
|
57
|
+
},
|
58
|
+
GridDestroy : function () {
|
59
|
+
return this.each(function(){
|
60
|
+
if ( this.grid ) {
|
61
|
+
if ( this.p.pager ) { // if not part of grid
|
62
|
+
$(this.p.pager).remove();
|
63
|
+
}
|
64
|
+
var gid = this.id;
|
65
|
+
try {
|
66
|
+
$("#gbox_"+gid).remove();
|
67
|
+
} catch (_) {}
|
68
|
+
}
|
69
|
+
});
|
70
|
+
},
|
71
|
+
GridUnload : function(){
|
72
|
+
return this.each(function(){
|
73
|
+
if ( !this.grid ) {return;}
|
74
|
+
var defgrid = {id: $(this).attr('id'),cl: $(this).attr('class')};
|
75
|
+
if (this.p.pager) {
|
76
|
+
$(this.p.pager).empty().removeClass("ui-state-default ui-jqgrid-pager corner-bottom");
|
77
|
+
}
|
78
|
+
var newtable = document.createElement('table');
|
79
|
+
$(newtable).attr({id:defgrid.id});
|
80
|
+
newtable.className = defgrid.cl;
|
81
|
+
var gid = this.id;
|
82
|
+
$(newtable).removeClass("ui-jqgrid-btable");
|
83
|
+
if( $(this.p.pager).parents("#gbox_"+gid).length === 1 ) {
|
84
|
+
$(newtable).insertBefore("#gbox_"+gid).show();
|
85
|
+
$(this.p.pager).insertBefore("#gbox_"+gid);
|
86
|
+
} else {
|
87
|
+
$(newtable).insertBefore("#gbox_"+gid).show();
|
88
|
+
}
|
89
|
+
$("#gbox_"+gid).remove();
|
90
|
+
});
|
91
|
+
},
|
92
|
+
setGridState : function(state) {
|
93
|
+
return this.each(function(){
|
94
|
+
if ( !this.grid ) {return;}
|
95
|
+
var $t = this;
|
96
|
+
if(state == 'hidden'){
|
97
|
+
$(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv","#gview_"+$t.p.id).slideUp("fast");
|
98
|
+
if($t.p.pager) {$($t.p.pager).slideUp("fast");}
|
99
|
+
if($t.p.toppager) {$($t.p.toppager).slideUp("fast");}
|
100
|
+
if($t.p.toolbar[0]===true) {
|
101
|
+
if( $t.p.toolbar[1]=='both') {
|
102
|
+
$($t.grid.ubDiv).slideUp("fast");
|
103
|
+
}
|
104
|
+
$($t.grid.uDiv).slideUp("fast");
|
105
|
+
}
|
106
|
+
if($t.p.footerrow) { $(".ui-jqgrid-sdiv","#gbox_"+$t.p.id).slideUp("fast"); }
|
107
|
+
$(".ui-jqgrid-titlebar-close span",$t.grid.cDiv).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s");
|
108
|
+
$t.p.gridstate = 'hidden';
|
109
|
+
} else if(state=='visible') {
|
110
|
+
$(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv","#gview_"+$t.p.id).slideDown("fast");
|
111
|
+
if($t.p.pager) {$($t.p.pager).slideDown("fast");}
|
112
|
+
if($t.p.toppager) {$($t.p.toppager).slideDown("fast");}
|
113
|
+
if($t.p.toolbar[0]===true) {
|
114
|
+
if( $t.p.toolbar[1]=='both') {
|
115
|
+
$($t.grid.ubDiv).slideDown("fast");
|
116
|
+
}
|
117
|
+
$($t.grid.uDiv).slideDown("fast");
|
118
|
+
}
|
119
|
+
if($t.p.footerrow) { $(".ui-jqgrid-sdiv","#gbox_"+$t.p.id).slideDown("fast"); }
|
120
|
+
$(".ui-jqgrid-titlebar-close span",$t.grid.cDiv).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n");
|
121
|
+
$t.p.gridstate = 'visible';
|
122
|
+
}
|
123
|
+
|
124
|
+
});
|
125
|
+
},
|
126
|
+
updateGridRows : function (data, rowidname, jsonreader) {
|
127
|
+
var nm, success=false, title;
|
128
|
+
this.each(function(){
|
129
|
+
var t = this, vl, ind, srow, sid;
|
130
|
+
if(!t.grid) {return false;}
|
131
|
+
if(!rowidname) { rowidname = "id"; }
|
132
|
+
if( data && data.length >0 ) {
|
133
|
+
$(data).each(function(j){
|
134
|
+
srow = this;
|
135
|
+
ind = t.rows.namedItem(srow[rowidname]);
|
136
|
+
if(ind) {
|
137
|
+
sid = srow[rowidname];
|
138
|
+
if(jsonreader === true){
|
139
|
+
if(t.p.jsonReader.repeatitems === true) {
|
140
|
+
if(t.p.jsonReader.cell) {srow = srow[t.p.jsonReader.cell];}
|
141
|
+
for (var k=0;k<srow.length;k++) {
|
142
|
+
vl = t.formatter( sid, srow[k], k, srow, 'edit');
|
143
|
+
title = t.p.colModel[k].title ? {"title":$.jgrid.stripHtml(vl)} : {};
|
144
|
+
if(t.p.treeGrid===true && nm == t.p.ExpandColumn) {
|
145
|
+
$("td:eq("+k+") > span:first",ind).html(vl).attr(title);
|
146
|
+
} else {
|
147
|
+
$("td:eq("+k+")",ind).html(vl).attr(title);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
success = true;
|
151
|
+
return true;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
$(t.p.colModel).each(function(i){
|
155
|
+
nm = jsonreader===true ? this.jsonmap || this.name :this.name;
|
156
|
+
if( srow[nm] !== undefined) {
|
157
|
+
vl = t.formatter( sid, srow[nm], i, srow, 'edit');
|
158
|
+
title = this.title ? {"title":$.jgrid.stripHtml(vl)} : {};
|
159
|
+
if(t.p.treeGrid===true && nm == t.p.ExpandColumn) {
|
160
|
+
$("td:eq("+i+") > span:first",ind).html(vl).attr(title);
|
161
|
+
} else {
|
162
|
+
$("td:eq("+i+")",ind).html(vl).attr(title);
|
163
|
+
}
|
164
|
+
success = true;
|
165
|
+
}
|
166
|
+
});
|
167
|
+
}
|
168
|
+
});
|
169
|
+
}
|
170
|
+
});
|
171
|
+
return success;
|
172
|
+
},
|
173
|
+
filterGrid : function(gridid,p){
|
174
|
+
p = $.extend({
|
175
|
+
gridModel : false,
|
176
|
+
gridNames : false,
|
177
|
+
gridToolbar : false,
|
178
|
+
filterModel: [], // label/name/stype/defval/surl/sopt
|
179
|
+
formtype : "horizontal", // horizontal/vertical
|
180
|
+
autosearch: true, // if set to false a serch button should be enabled.
|
181
|
+
formclass: "filterform",
|
182
|
+
tableclass: "filtertable",
|
183
|
+
buttonclass: "filterbutton",
|
184
|
+
searchButton: "Search",
|
185
|
+
clearButton: "Clear",
|
186
|
+
enableSearch : false,
|
187
|
+
enableClear: false,
|
188
|
+
beforeSearch: null,
|
189
|
+
afterSearch: null,
|
190
|
+
beforeClear: null,
|
191
|
+
afterClear: null,
|
192
|
+
url : '',
|
193
|
+
marksearched: true
|
194
|
+
},p || {});
|
195
|
+
return this.each(function(){
|
196
|
+
var self = this;
|
197
|
+
this.p = p;
|
198
|
+
if(this.p.filterModel.length === 0 && this.p.gridModel===false) { alert("No filter is set"); return;}
|
199
|
+
if( !gridid) {alert("No target grid is set!"); return;}
|
200
|
+
this.p.gridid = gridid.indexOf("#") != -1 ? gridid : "#"+gridid;
|
201
|
+
var gcolMod = $(this.p.gridid).jqGrid("getGridParam",'colModel');
|
202
|
+
if(gcolMod) {
|
203
|
+
if( this.p.gridModel === true) {
|
204
|
+
var thegrid = $(this.p.gridid)[0];
|
205
|
+
var sh;
|
206
|
+
// we should use the options search, edittype, editoptions
|
207
|
+
// additionally surl and defval can be added in grid colModel
|
208
|
+
$.each(gcolMod, function (i,n) {
|
209
|
+
var tmpFil = [];
|
210
|
+
this.search = this.search === false ? false : true;
|
211
|
+
if(this.editrules && this.editrules.searchhidden === true) {
|
212
|
+
sh = true;
|
213
|
+
} else {
|
214
|
+
if(this.hidden === true ) {
|
215
|
+
sh = false;
|
216
|
+
} else {
|
217
|
+
sh = true;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
if( this.search === true && sh === true) {
|
221
|
+
if(self.p.gridNames===true) {
|
222
|
+
tmpFil.label = thegrid.p.colNames[i];
|
223
|
+
} else {
|
224
|
+
tmpFil.label = '';
|
225
|
+
}
|
226
|
+
tmpFil.name = this.name;
|
227
|
+
tmpFil.index = this.index || this.name;
|
228
|
+
// we support only text and selects, so all other to text
|
229
|
+
tmpFil.stype = this.edittype || 'text';
|
230
|
+
if(tmpFil.stype != 'select' ) {
|
231
|
+
tmpFil.stype = 'text';
|
232
|
+
}
|
233
|
+
tmpFil.defval = this.defval || '';
|
234
|
+
tmpFil.surl = this.surl || '';
|
235
|
+
tmpFil.sopt = this.editoptions || {};
|
236
|
+
tmpFil.width = this.width;
|
237
|
+
self.p.filterModel.push(tmpFil);
|
238
|
+
}
|
239
|
+
});
|
240
|
+
} else {
|
241
|
+
$.each(self.p.filterModel,function(i,n) {
|
242
|
+
for(var j=0;j<gcolMod.length;j++) {
|
243
|
+
if(this.name == gcolMod[j].name) {
|
244
|
+
this.index = gcolMod[j].index || this.name;
|
245
|
+
break;
|
246
|
+
}
|
247
|
+
}
|
248
|
+
if(!this.index) {
|
249
|
+
this.index = this.name;
|
250
|
+
}
|
251
|
+
});
|
252
|
+
}
|
253
|
+
} else {
|
254
|
+
alert("Could not get grid colModel"); return;
|
255
|
+
}
|
256
|
+
var triggerSearch = function() {
|
257
|
+
var sdata={}, j=0, v;
|
258
|
+
var gr = $(self.p.gridid)[0], nm;
|
259
|
+
gr.p.searchdata = {};
|
260
|
+
if($.isFunction(self.p.beforeSearch)){self.p.beforeSearch();}
|
261
|
+
$.each(self.p.filterModel,function(i,n){
|
262
|
+
nm = this.index;
|
263
|
+
switch (this.stype) {
|
264
|
+
case 'select' :
|
265
|
+
v = $("select[name="+nm+"]",self).val();
|
266
|
+
if(v) {
|
267
|
+
sdata[nm] = v;
|
268
|
+
if(self.p.marksearched){
|
269
|
+
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
|
270
|
+
}
|
271
|
+
j++;
|
272
|
+
} else {
|
273
|
+
if(self.p.marksearched){
|
274
|
+
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
|
275
|
+
}
|
276
|
+
try {
|
277
|
+
delete gr.p.postData[this.index];
|
278
|
+
} catch (e) {}
|
279
|
+
}
|
280
|
+
break;
|
281
|
+
default:
|
282
|
+
v = $("input[name="+nm+"]",self).val();
|
283
|
+
if(v) {
|
284
|
+
sdata[nm] = v;
|
285
|
+
if(self.p.marksearched){
|
286
|
+
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
|
287
|
+
}
|
288
|
+
j++;
|
289
|
+
} else {
|
290
|
+
if(self.p.marksearched){
|
291
|
+
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
|
292
|
+
}
|
293
|
+
try {
|
294
|
+
delete gr.p.postData[this.index];
|
295
|
+
} catch(e) {}
|
296
|
+
}
|
297
|
+
}
|
298
|
+
});
|
299
|
+
var sd = j>0 ? true : false;
|
300
|
+
$.extend(gr.p.postData,sdata);
|
301
|
+
var saveurl;
|
302
|
+
if(self.p.url) {
|
303
|
+
saveurl = $(gr).jqGrid("getGridParam",'url');
|
304
|
+
$(gr).jqGrid("setGridParam",{url:self.p.url});
|
305
|
+
}
|
306
|
+
$(gr).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]);
|
307
|
+
if(saveurl) {$(gr).jqGrid("setGridParam",{url:saveurl});}
|
308
|
+
if($.isFunction(self.p.afterSearch)){self.p.afterSearch();}
|
309
|
+
};
|
310
|
+
var clearSearch = function(){
|
311
|
+
var sdata={}, v, j=0;
|
312
|
+
var gr = $(self.p.gridid)[0], nm;
|
313
|
+
if($.isFunction(self.p.beforeClear)){self.p.beforeClear();}
|
314
|
+
$.each(self.p.filterModel,function(i,n){
|
315
|
+
nm = this.index;
|
316
|
+
v = (this.defval) ? this.defval : "";
|
317
|
+
if(!this.stype){this.stype='text';}
|
318
|
+
switch (this.stype) {
|
319
|
+
case 'select' :
|
320
|
+
var v1;
|
321
|
+
$("select[name="+nm+"] option",self).each(function (i){
|
322
|
+
if(i===0) { this.selected = true; }
|
323
|
+
if ($(this).text() == v) {
|
324
|
+
this.selected = true;
|
325
|
+
v1 = $(this).val();
|
326
|
+
return false;
|
327
|
+
}
|
328
|
+
});
|
329
|
+
if(v1) {
|
330
|
+
// post the key and not the text
|
331
|
+
sdata[nm] = v1;
|
332
|
+
if(self.p.marksearched){
|
333
|
+
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
|
334
|
+
}
|
335
|
+
j++;
|
336
|
+
} else {
|
337
|
+
if(self.p.marksearched){
|
338
|
+
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
|
339
|
+
}
|
340
|
+
try {
|
341
|
+
delete gr.p.postData[this.index];
|
342
|
+
} catch (e) {}
|
343
|
+
}
|
344
|
+
break;
|
345
|
+
case 'text':
|
346
|
+
$("input[name="+nm+"]",self).val(v);
|
347
|
+
if(v) {
|
348
|
+
sdata[nm] = v;
|
349
|
+
if(self.p.marksearched){
|
350
|
+
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
|
351
|
+
}
|
352
|
+
j++;
|
353
|
+
} else {
|
354
|
+
if(self.p.marksearched){
|
355
|
+
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
|
356
|
+
}
|
357
|
+
try {
|
358
|
+
delete gr.p.postData[this.index];
|
359
|
+
} catch (e) {}
|
360
|
+
}
|
361
|
+
break;
|
362
|
+
}
|
363
|
+
});
|
364
|
+
var sd = j>0 ? true : false;
|
365
|
+
$.extend(gr.p.postData,sdata);
|
366
|
+
var saveurl;
|
367
|
+
if(self.p.url) {
|
368
|
+
saveurl = $(gr).jqGrid("getGridParam",'url');
|
369
|
+
$(gr).jqGrid("setGridParam",{url:self.p.url});
|
370
|
+
}
|
371
|
+
$(gr).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]);
|
372
|
+
if(saveurl) {$(gr).jqGrid("setGridParam",{url:saveurl});}
|
373
|
+
if($.isFunction(self.p.afterClear)){self.p.afterClear();}
|
374
|
+
};
|
375
|
+
var tbl;
|
376
|
+
var formFill = function(){
|
377
|
+
var tr = document.createElement("tr");
|
378
|
+
var tr1, sb, cb,tl,td;
|
379
|
+
if(self.p.formtype=='horizontal'){
|
380
|
+
$(tbl).append(tr);
|
381
|
+
}
|
382
|
+
$.each(self.p.filterModel,function(i,n){
|
383
|
+
tl = document.createElement("td");
|
384
|
+
$(tl).append("<label for='"+this.name+"'>"+this.label+"</label>");
|
385
|
+
td = document.createElement("td");
|
386
|
+
var $t=this;
|
387
|
+
if(!this.stype) { this.stype='text';}
|
388
|
+
switch (this.stype)
|
389
|
+
{
|
390
|
+
case "select":
|
391
|
+
if(this.surl) {
|
392
|
+
// data returned should have already constructed html select
|
393
|
+
$(td).load(this.surl,function(){
|
394
|
+
if($t.defval) { $("select",this).val($t.defval); }
|
395
|
+
$("select",this).attr({name:$t.index || $t.name, id: "sg_"+$t.name});
|
396
|
+
if($t.sopt) { $("select",this).attr($t.sopt); }
|
397
|
+
if(self.p.gridToolbar===true && $t.width) {
|
398
|
+
$("select",this).width($t.width);
|
399
|
+
}
|
400
|
+
if(self.p.autosearch===true){
|
401
|
+
$("select",this).change(function(e){
|
402
|
+
triggerSearch();
|
403
|
+
return false;
|
404
|
+
});
|
405
|
+
}
|
406
|
+
});
|
407
|
+
} else {
|
408
|
+
// sopt to construct the values
|
409
|
+
if($t.sopt.value) {
|
410
|
+
var oSv = $t.sopt.value;
|
411
|
+
var elem = document.createElement("select");
|
412
|
+
$(elem).attr({name:$t.index || $t.name, id: "sg_"+$t.name}).attr($t.sopt);
|
413
|
+
var so, sv, ov;
|
414
|
+
if(typeof oSv === "string") {
|
415
|
+
so = oSv.split(";");
|
416
|
+
for(var k=0; k<so.length;k++){
|
417
|
+
sv = so[k].split(":");
|
418
|
+
ov = document.createElement("option");
|
419
|
+
ov.value = sv[0]; ov.innerHTML = sv[1];
|
420
|
+
if (sv[1]==$t.defval) { ov.selected ="selected"; }
|
421
|
+
elem.appendChild(ov);
|
422
|
+
}
|
423
|
+
} else if(typeof oSv === "object" ) {
|
424
|
+
for ( var key in oSv) {
|
425
|
+
if(oSv.hasOwnProperty(key)) {
|
426
|
+
i++;
|
427
|
+
ov = document.createElement("option");
|
428
|
+
ov.value = key; ov.innerHTML = oSv[key];
|
429
|
+
if (oSv[key]==$t.defval) { ov.selected ="selected"; }
|
430
|
+
elem.appendChild(ov);
|
431
|
+
}
|
432
|
+
}
|
433
|
+
}
|
434
|
+
if(self.p.gridToolbar===true && $t.width) {
|
435
|
+
$(elem).width($t.width);
|
436
|
+
}
|
437
|
+
$(td).append(elem);
|
438
|
+
if(self.p.autosearch===true){
|
439
|
+
$(elem).change(function(e){
|
440
|
+
triggerSearch();
|
441
|
+
return false;
|
442
|
+
});
|
443
|
+
}
|
444
|
+
}
|
445
|
+
}
|
446
|
+
break;
|
447
|
+
case 'text':
|
448
|
+
var df = this.defval ? this.defval: "";
|
449
|
+
$(td).append("<input type='text' name='"+(this.index || this.name)+"' id='sg_"+this.name+"' value='"+df+"'/>");
|
450
|
+
if($t.sopt) { $("input",td).attr($t.sopt); }
|
451
|
+
if(self.p.gridToolbar===true && $t.width) {
|
452
|
+
if($.browser.msie) {
|
453
|
+
$("input",td).width($t.width-4);
|
454
|
+
} else {
|
455
|
+
$("input",td).width($t.width-2);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
if(self.p.autosearch===true){
|
459
|
+
$("input",td).keypress(function(e){
|
460
|
+
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
|
461
|
+
if(key == 13){
|
462
|
+
triggerSearch();
|
463
|
+
return false;
|
464
|
+
}
|
465
|
+
return this;
|
466
|
+
});
|
467
|
+
}
|
468
|
+
break;
|
469
|
+
}
|
470
|
+
if(self.p.formtype=='horizontal'){
|
471
|
+
if(self.p.gridToolbar===true && self.p.gridNames===false) {
|
472
|
+
$(tr).append(td);
|
473
|
+
} else {
|
474
|
+
$(tr).append(tl).append(td);
|
475
|
+
}
|
476
|
+
$(tr).append(td);
|
477
|
+
} else {
|
478
|
+
tr1 = document.createElement("tr");
|
479
|
+
$(tr1).append(tl).append(td);
|
480
|
+
$(tbl).append(tr1);
|
481
|
+
}
|
482
|
+
});
|
483
|
+
td = document.createElement("td");
|
484
|
+
if(self.p.enableSearch === true){
|
485
|
+
sb = "<input type='button' id='sButton' class='"+self.p.buttonclass+"' value='"+self.p.searchButton+"'/>";
|
486
|
+
$(td).append(sb);
|
487
|
+
$("input#sButton",td).click(function(){
|
488
|
+
triggerSearch();
|
489
|
+
return false;
|
490
|
+
});
|
491
|
+
}
|
492
|
+
if(self.p.enableClear === true) {
|
493
|
+
cb = "<input type='button' id='cButton' class='"+self.p.buttonclass+"' value='"+self.p.clearButton+"'/>";
|
494
|
+
$(td).append(cb);
|
495
|
+
$("input#cButton",td).click(function(){
|
496
|
+
clearSearch();
|
497
|
+
return false;
|
498
|
+
});
|
499
|
+
}
|
500
|
+
if(self.p.enableClear === true || self.p.enableSearch === true) {
|
501
|
+
if(self.p.formtype=='horizontal') {
|
502
|
+
$(tr).append(td);
|
503
|
+
} else {
|
504
|
+
tr1 = document.createElement("tr");
|
505
|
+
$(tr1).append("<td> </td>").append(td);
|
506
|
+
$(tbl).append(tr1);
|
507
|
+
}
|
508
|
+
}
|
509
|
+
};
|
510
|
+
var frm = $("<form name='SearchForm' style=display:inline;' class='"+this.p.formclass+"'></form>");
|
511
|
+
tbl =$("<table class='"+this.p.tableclass+"' cellspacing='0' cellpading='0' border='0'><tbody></tbody></table>");
|
512
|
+
$(frm).append(tbl);
|
513
|
+
formFill();
|
514
|
+
$(this).append(frm);
|
515
|
+
this.triggerSearch = triggerSearch;
|
516
|
+
this.clearSearch = clearSearch;
|
517
|
+
});
|
518
|
+
},
|
519
|
+
filterToolbar : function(p){
|
520
|
+
p = $.extend({
|
521
|
+
autosearch: true,
|
522
|
+
searchOnEnter : true,
|
523
|
+
beforeSearch: null,
|
524
|
+
afterSearch: null,
|
525
|
+
beforeClear: null,
|
526
|
+
afterClear: null,
|
527
|
+
searchurl : '',
|
528
|
+
stringResult: false,
|
529
|
+
groupOp: 'AND',
|
530
|
+
defaultSearch : "bw"
|
531
|
+
},p || {});
|
532
|
+
return this.each(function(){
|
533
|
+
var $t = this;
|
534
|
+
var triggerToolbar = function() {
|
535
|
+
var sdata={}, j=0, v, nm, sopt={},so;
|
536
|
+
$.each($t.p.colModel,function(i,n){
|
537
|
+
nm = this.index || this.name;
|
538
|
+
switch (this.stype) {
|
539
|
+
case 'select' :
|
540
|
+
so = (this.searchoptions && this.searchoptions.sopt) ? this.searchoptions.sopt[0] : 'eq';
|
541
|
+
v = $("select[name="+nm+"]",$t.grid.hDiv).val();
|
542
|
+
if(v) {
|
543
|
+
sdata[nm] = v;
|
544
|
+
sopt[nm] = so;
|
545
|
+
j++;
|
546
|
+
} else {
|
547
|
+
try {
|
548
|
+
delete $t.p.postData[nm];
|
549
|
+
} catch (e) {}
|
550
|
+
}
|
551
|
+
break;
|
552
|
+
case 'text':
|
553
|
+
so = (this.searchoptions && this.searchoptions.sopt) ? this.searchoptions.sopt[0] : p.defaultSearch;
|
554
|
+
v = $("input[name="+nm+"]",$t.grid.hDiv).val();
|
555
|
+
if(v) {
|
556
|
+
sdata[nm] = v;
|
557
|
+
sopt[nm] = so;
|
558
|
+
j++;
|
559
|
+
} else {
|
560
|
+
try {
|
561
|
+
delete $t.p.postData[nm];
|
562
|
+
} catch (e) {}
|
563
|
+
}
|
564
|
+
break;
|
565
|
+
}
|
566
|
+
});
|
567
|
+
var sd = j>0 ? true : false;
|
568
|
+
if(p.stringResult === true || $t.p.datatype == "local") {
|
569
|
+
var ruleGroup = "{\"groupOp\":\"" + p.groupOp + "\",\"rules\":[";
|
570
|
+
var gi=0;
|
571
|
+
$.each(sdata,function(i,n){
|
572
|
+
if (gi > 0) {ruleGroup += ",";}
|
573
|
+
ruleGroup += "{\"field\":\"" + i + "\",";
|
574
|
+
ruleGroup += "\"op\":\"" + sopt[i] + "\",";
|
575
|
+
ruleGroup += "\"data\":\"" + n + "\"}";
|
576
|
+
gi++;
|
577
|
+
});
|
578
|
+
ruleGroup += "]}";
|
579
|
+
$.extend($t.p.postData,{filters:ruleGroup});
|
580
|
+
} else {
|
581
|
+
$.extend($t.p.postData,sdata);
|
582
|
+
}
|
583
|
+
var saveurl;
|
584
|
+
if($t.p.searchurl) {
|
585
|
+
saveurl = $t.p.url;
|
586
|
+
$($t).jqGrid("setGridParam",{url:$t.p.searchurl});
|
587
|
+
}
|
588
|
+
var bsr = false;
|
589
|
+
if($.isFunction(p.beforeSearch)){bsr = p.beforeSearch.call($t);}
|
590
|
+
if(!bsr) { $($t).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]); }
|
591
|
+
if(saveurl) {$($t).jqGrid("setGridParam",{url:saveurl});}
|
592
|
+
if($.isFunction(p.afterSearch)){p.afterSearch();}
|
593
|
+
};
|
594
|
+
var clearToolbar = function(trigger){
|
595
|
+
var sdata={}, v, j=0, nm;
|
596
|
+
trigger = (typeof trigger != 'boolean') ? true : trigger;
|
597
|
+
$.each($t.p.colModel,function(i,n){
|
598
|
+
v = (this.searchoptions && this.searchoptions.defaultValue) ? this.searchoptions.defaultValue : "";
|
599
|
+
nm = this.index || this.name;
|
600
|
+
switch (this.stype) {
|
601
|
+
case 'select' :
|
602
|
+
var v1;
|
603
|
+
$("select[name="+nm+"] option",$t.grid.hDiv).each(function (i){
|
604
|
+
if(i===0) { this.selected = true; }
|
605
|
+
if ($(this).text() == v) {
|
606
|
+
this.selected = true;
|
607
|
+
v1 = $(this).val();
|
608
|
+
return false;
|
609
|
+
}
|
610
|
+
});
|
611
|
+
if (v1) {
|
612
|
+
// post the key and not the text
|
613
|
+
sdata[nm] = v1;
|
614
|
+
j++;
|
615
|
+
} else {
|
616
|
+
try {
|
617
|
+
delete $t.p.postData[nm];
|
618
|
+
} catch(e) {}
|
619
|
+
}
|
620
|
+
break;
|
621
|
+
case 'text':
|
622
|
+
$("input[name="+nm+"]",$t.grid.hDiv).val(v);
|
623
|
+
if(v) {
|
624
|
+
sdata[nm] = v;
|
625
|
+
j++;
|
626
|
+
} else {
|
627
|
+
try {
|
628
|
+
delete $t.p.postData[nm];
|
629
|
+
} catch (e){}
|
630
|
+
}
|
631
|
+
break;
|
632
|
+
}
|
633
|
+
});
|
634
|
+
var sd = j>0 ? true : false;
|
635
|
+
if(p.stringResult === true || $t.p.datatype == "local") {
|
636
|
+
var ruleGroup = "{\"groupOp\":\"" + p.groupOp + "\",\"rules\":[";
|
637
|
+
var gi=0;
|
638
|
+
$.each(sdata,function(i,n){
|
639
|
+
if (gi > 0) {ruleGroup += ",";}
|
640
|
+
ruleGroup += "{\"field\":\"" + i + "\",";
|
641
|
+
ruleGroup += "\"op\":\"" + "eq" + "\",";
|
642
|
+
ruleGroup += "\"data\":\"" + n + "\"}";
|
643
|
+
gi++;
|
644
|
+
});
|
645
|
+
ruleGroup += "]}";
|
646
|
+
$.extend($t.p.postData,{filters:ruleGroup});
|
647
|
+
} else {
|
648
|
+
$.extend($t.p.postData,sdata);
|
649
|
+
}
|
650
|
+
var saveurl;
|
651
|
+
if($t.p.searchurl) {
|
652
|
+
saveurl = $t.p.url;
|
653
|
+
$($t).jqGrid("setGridParam",{url:$t.p.searchurl});
|
654
|
+
}
|
655
|
+
var bcv = false;
|
656
|
+
if($.isFunction(p.beforeClear)){bcv = p.beforeClear.call($t);}
|
657
|
+
if(!bcv) {
|
658
|
+
if(trigger) {
|
659
|
+
$($t).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]);
|
660
|
+
}
|
661
|
+
}
|
662
|
+
if(saveurl) {$($t).jqGrid("setGridParam",{url:saveurl});}
|
663
|
+
if($.isFunction(p.afterClear)){p.afterClear();}
|
664
|
+
};
|
665
|
+
var toggleToolbar = function(){
|
666
|
+
var trow = $("tr.ui-search-toolbar",$t.grid.hDiv);
|
667
|
+
if(trow.css("display")=='none') { trow.show(); }
|
668
|
+
else { trow.hide(); }
|
669
|
+
};
|
670
|
+
// create the row
|
671
|
+
function bindEvents(selector, events) {
|
672
|
+
var jElem = $(selector);
|
673
|
+
if (jElem[0]) {
|
674
|
+
jQuery.each(events, function() {
|
675
|
+
if (this.data !== undefined) {
|
676
|
+
jElem.bind(this.type, this.data, this.fn);
|
677
|
+
} else {
|
678
|
+
jElem.bind(this.type, this.fn);
|
679
|
+
}
|
680
|
+
});
|
681
|
+
}
|
682
|
+
}
|
683
|
+
var tr = $("<tr class='ui-search-toolbar' role='rowheader'></tr>");
|
684
|
+
var timeoutHnd;
|
685
|
+
$.each($t.p.colModel,function(i,n){
|
686
|
+
var cm=this, thd , th, soptions,surl,self;
|
687
|
+
th = $("<th role='columnheader' class='ui-state-default ui-th-column ui-th-"+$t.p.direction+"'></th>");
|
688
|
+
thd = $("<div style='width:100%;position:relative;height:100%;padding-right:0.3em;'></div>");
|
689
|
+
if(this.hidden===true) { $(th).css("display","none");}
|
690
|
+
this.search = this.search === false ? false : true;
|
691
|
+
if(typeof this.stype == 'undefined' ) {this.stype='text';}
|
692
|
+
soptions = $.extend({},this.searchoptions || {});
|
693
|
+
if(this.search){
|
694
|
+
switch (this.stype)
|
695
|
+
{
|
696
|
+
case "select":
|
697
|
+
surl = this.surl || soptions.dataUrl;
|
698
|
+
if(surl) {
|
699
|
+
// data returned should have already constructed html select
|
700
|
+
// primitive jQuery load
|
701
|
+
self = thd;
|
702
|
+
$.ajax($.extend({
|
703
|
+
url: surl,
|
704
|
+
dataType: "html",
|
705
|
+
complete: function(res,status) {
|
706
|
+
if(soptions.buildSelect !== undefined) {
|
707
|
+
var d = soptions.buildSelect(res);
|
708
|
+
if (d) { $(self).append(d); }
|
709
|
+
} else {
|
710
|
+
$(self).append(res.responseText);
|
711
|
+
}
|
712
|
+
if(soptions.defaultValue) { $("select",self).val(soptions.defaultValue); }
|
713
|
+
$("select",self).attr({name:cm.index || cm.name, id: "gs_"+cm.name});
|
714
|
+
if(soptions.attr) {$("select",self).attr(soptions.attr);}
|
715
|
+
$("select",self).css({width: "100%"});
|
716
|
+
// preserve autoserch
|
717
|
+
if(soptions.dataInit !== undefined) { soptions.dataInit($("select",self)[0]); }
|
718
|
+
if(soptions.dataEvents !== undefined) { bindEvents($("select",self)[0],soptions.dataEvents); }
|
719
|
+
if(p.autosearch===true){
|
720
|
+
$("select",self).change(function(e){
|
721
|
+
triggerToolbar();
|
722
|
+
return false;
|
723
|
+
});
|
724
|
+
}
|
725
|
+
res=null;
|
726
|
+
}
|
727
|
+
}, $.jgrid.ajaxOptions, $t.p.ajaxSelectOptions || {} ));
|
728
|
+
} else {
|
729
|
+
var oSv;
|
730
|
+
if(cm.searchoptions && cm.searchoptions.value) {
|
731
|
+
oSv = cm.searchoptions.value;
|
732
|
+
} else if(cm.editoptions && cm.editoptions.value) {
|
733
|
+
oSv = cm.editoptions.value;
|
734
|
+
}
|
735
|
+
if (oSv) {
|
736
|
+
var elem = document.createElement("select");
|
737
|
+
elem.style.width = "100%";
|
738
|
+
$(elem).attr({name:cm.index || cm.name, id: "gs_"+cm.name});
|
739
|
+
var so, sv, ov;
|
740
|
+
if(typeof oSv === "string") {
|
741
|
+
so = oSv.split(";");
|
742
|
+
for(var k=0; k<so.length;k++){
|
743
|
+
sv = so[k].split(":");
|
744
|
+
ov = document.createElement("option");
|
745
|
+
ov.value = sv[0]; ov.innerHTML = sv[1];
|
746
|
+
elem.appendChild(ov);
|
747
|
+
}
|
748
|
+
} else if(typeof oSv === "object" ) {
|
749
|
+
for ( var key in oSv) {
|
750
|
+
if(oSv.hasOwnProperty(key)) {
|
751
|
+
ov = document.createElement("option");
|
752
|
+
ov.value = key; ov.innerHTML = oSv[key];
|
753
|
+
elem.appendChild(ov);
|
754
|
+
}
|
755
|
+
}
|
756
|
+
}
|
757
|
+
if(soptions.defaultValue) { $(elem).val(soptions.defaultValue); }
|
758
|
+
if(soptions.attr) {$(elem).attr(soptions.attr);}
|
759
|
+
if(soptions.dataInit !== undefined) { soptions.dataInit(elem); }
|
760
|
+
if(soptions.dataEvents !== undefined) { bindEvents(elem, soptions.dataEvents); }
|
761
|
+
$(thd).append(elem);
|
762
|
+
if(p.autosearch===true){
|
763
|
+
$(elem).change(function(e){
|
764
|
+
triggerToolbar();
|
765
|
+
return false;
|
766
|
+
});
|
767
|
+
}
|
768
|
+
}
|
769
|
+
}
|
770
|
+
break;
|
771
|
+
case 'text':
|
772
|
+
var df = soptions.defaultValue ? soptions.defaultValue: "";
|
773
|
+
$(thd).append("<input type='text' style='width:95%;padding:0px;' name='"+(cm.index || cm.name)+"' id='gs_"+cm.name+"' value='"+df+"'/>");
|
774
|
+
if(soptions.attr) {$("input",thd).attr(soptions.attr);}
|
775
|
+
if(soptions.dataInit !== undefined) { soptions.dataInit($("input",thd)[0]); }
|
776
|
+
if(soptions.dataEvents !== undefined) { bindEvents($("input",thd)[0], soptions.dataEvents); }
|
777
|
+
if(p.autosearch===true){
|
778
|
+
if(p.searchOnEnter) {
|
779
|
+
$("input",thd).keypress(function(e){
|
780
|
+
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
|
781
|
+
if(key == 13){
|
782
|
+
triggerToolbar();
|
783
|
+
return false;
|
784
|
+
}
|
785
|
+
return this;
|
786
|
+
});
|
787
|
+
} else {
|
788
|
+
$("input",thd).keydown(function(e){
|
789
|
+
var key = e.which;
|
790
|
+
switch (key) {
|
791
|
+
case 13:
|
792
|
+
return false;
|
793
|
+
case 9 :
|
794
|
+
case 16:
|
795
|
+
case 37:
|
796
|
+
case 38:
|
797
|
+
case 39:
|
798
|
+
case 40:
|
799
|
+
case 27:
|
800
|
+
break;
|
801
|
+
default :
|
802
|
+
if(timeoutHnd) { clearTimeout(timeoutHnd); }
|
803
|
+
timeoutHnd = setTimeout(function(){triggerToolbar();},500);
|
804
|
+
}
|
805
|
+
});
|
806
|
+
}
|
807
|
+
}
|
808
|
+
break;
|
809
|
+
}
|
810
|
+
}
|
811
|
+
$(th).append(thd);
|
812
|
+
$(tr).append(th);
|
813
|
+
});
|
814
|
+
$("table thead",$t.grid.hDiv).append(tr);
|
815
|
+
this.triggerToolbar = triggerToolbar;
|
816
|
+
this.clearToolbar = clearToolbar;
|
817
|
+
this.toggleToolbar = toggleToolbar;
|
818
|
+
});
|
819
|
+
}
|
820
|
+
});
|
818
821
|
})(jQuery);
|