rails_jq_grid 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYRIGHT.txt +17 -0
- data/GPL-LICENSE +675 -0
- data/README.rdoc +176 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/app/helpers/rails_jq_grid/jq_grid_css_helper.rb +29 -0
- data/app/helpers/rails_jq_grid/jq_grid_helper.rb +21 -0
- data/app/helpers/rails_jq_grid/jq_grid_js_helper.rb +30 -0
- data/app/models/rails_jq_grid/jq_grid.rb +315 -0
- data/app/models/rails_jq_grid/jq_grid_column.rb +33 -0
- data/app/models/rails_jq_grid/jq_grid_method_missing.rb +50 -0
- data/app/models/rails_jq_grid/jq_grid_option_or_method.rb +46 -0
- data/lib/rails_jq_grid/acts_as_jq_grid_able.rb +76 -0
- data/lib/rails_jq_grid/acts_as_jq_grid_data_source.rb +34 -0
- data/lib/rails_jq_grid/engine.rb +23 -0
- data/lib/rails_jq_grid.rb +7 -0
- data/lib/tasks/rails_jq_grid.rake +1 -0
- data/public/javascripts/rails-jqgrid/Changes.txt +1160 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg1251.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cat.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cn.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cs.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-de.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-dk.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-el.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-en.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-es.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fa.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fi.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fr.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-he.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-hu.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-is.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-it.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ja.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-nl.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-no.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pl.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt-br.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ro.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ru.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-sk.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-sv.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-tr.js +1 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ua.js +1 -0
- data/public/javascripts/rails-jqgrid/install.txt +43 -0
- data/public/javascripts/rails-jqgrid/jquery-1.4.2.min.js +154 -0
- data/public/javascripts/rails-jqgrid/jquery-ui-1.8.4.custom.min.js +763 -0
- data/public/javascripts/rails-jqgrid/jquery.jqGrid.min.js +445 -0
- data/public/javascripts/rails-jqgrid/src/JsonXml.js +330 -0
- data/public/javascripts/rails-jqgrid/src/css/ellipsis-xbl.xml +13 -0
- data/public/javascripts/rails-jqgrid/src/css/jquery.searchFilter.css +7 -0
- data/public/javascripts/rails-jqgrid/src/css/ui.jqgrid.css +129 -0
- data/public/javascripts/rails-jqgrid/src/css/ui.multiselect.css +30 -0
- data/public/javascripts/rails-jqgrid/src/grid.base.js +3003 -0
- data/public/javascripts/rails-jqgrid/src/grid.celledit.js +486 -0
- data/public/javascripts/rails-jqgrid/src/grid.common.js +636 -0
- data/public/javascripts/rails-jqgrid/src/grid.custom.js +818 -0
- data/public/javascripts/rails-jqgrid/src/grid.formedit.js +1872 -0
- data/public/javascripts/rails-jqgrid/src/grid.import.js +201 -0
- data/public/javascripts/rails-jqgrid/src/grid.inlinedit.js +250 -0
- data/public/javascripts/rails-jqgrid/src/grid.jqueryui.js +503 -0
- data/public/javascripts/rails-jqgrid/src/grid.loader.js +47 -0
- data/public/javascripts/rails-jqgrid/src/grid.postext.js +64 -0
- data/public/javascripts/rails-jqgrid/src/grid.setcolumns.js +126 -0
- data/public/javascripts/rails-jqgrid/src/grid.subgrid.js +260 -0
- data/public/javascripts/rails-jqgrid/src/grid.tbltogrid.js +106 -0
- data/public/javascripts/rails-jqgrid/src/grid.treegrid.js +483 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg.js +132 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg1251.js +132 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cat.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cn.js +132 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cs.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-de.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-dk.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-el.js +126 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-en.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-es.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fa.js +125 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fi.js +130 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fr.js +126 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-he.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-hu.js +129 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-is.js +126 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-it.js +1 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ja.js +155 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-nl.js +149 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-no.js +1 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pl.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt-br.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt.js +125 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ro.js +139 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ru.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sk.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sv.js +127 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-tr.js +126 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ua.js +127 -0
- data/public/javascripts/rails-jqgrid/src/jqDnR.js +68 -0
- data/public/javascripts/rails-jqgrid/src/jqModal.js +69 -0
- data/public/javascripts/rails-jqgrid/src/jquery.fmatter.js +542 -0
- data/public/javascripts/rails-jqgrid/src/jquery.searchFilter.js +716 -0
- data/public/javascripts/rails-jqgrid/src/ui.multiselect.js +314 -0
- data/public/stylesheets/rails-jqgrid/ellipsis-xbl.xml +13 -0
- data/public/stylesheets/rails-jqgrid/themes/AUTHORS.txt +30 -0
- data/public/stylesheets/rails-jqgrid/themes/GPL-LICENSE.txt +278 -0
- data/public/stylesheets/rails-jqgrid/themes/MIT-LICENSE.txt +25 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/smoothness/jquery-ui-1.8.4.custom.css +572 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_flat_55_999999_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_flat_75_aaaaaa_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_45_0078ae_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_55_f8da4e_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_glass_75_79c9ec_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_45_e14f1c_500x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_50_6eac2c_500x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_gloss-wave_75_2191c0_500x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_0078ae_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_056b93_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_d8e7f3_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_e0fdff_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_f5e175_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_f7a50d_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/images/ui-icons_fcd113_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/start/jquery-ui-1.8.4.custom.css +573 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_flat_30_cccccc_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_flat_50_5c5c5c_40x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_20_555555_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_40_0078a3_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_glass_40_ffc73d_1x400.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_gloss-wave_25_333333_500x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_highlight-soft_80_eeeeee_1x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_inset-soft_25_000000_1x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-bg_inset-soft_30_f58400_1x100.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_222222_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_4b8e0b_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_a83300_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_cccccc_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/images/ui-icons_ffffff_256x240.png +0 -0
- data/public/stylesheets/rails-jqgrid/themes/ui-darkness/jquery-ui-1.8.4.custom.css +572 -0
- data/public/stylesheets/rails-jqgrid/themes/version.txt +1 -0
- data/public/stylesheets/rails-jqgrid/ui.jqgrid.css +2 -0
- data/rails_jq_grid.gemspec +200 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +8 -0
- metadata +240 -0
@@ -0,0 +1,1872 @@
|
|
1
|
+
;(function($){
|
2
|
+
/**
|
3
|
+
* jqGrid extension for form editing Grid Data
|
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
|
+
var rp_ge = null;
|
11
|
+
$.jgrid.extend({
|
12
|
+
searchGrid : function (p) {
|
13
|
+
p = $.extend({
|
14
|
+
recreateFilter: false,
|
15
|
+
drag: true,
|
16
|
+
sField:'searchField',
|
17
|
+
sValue:'searchString',
|
18
|
+
sOper: 'searchOper',
|
19
|
+
sFilter: 'filters',
|
20
|
+
loadDefaults: true, // this options activates loading of default filters from grid's postData for Multipe Search only.
|
21
|
+
beforeShowSearch: null,
|
22
|
+
afterShowSearch : null,
|
23
|
+
onInitializeSearch: null,
|
24
|
+
closeAfterSearch : false,
|
25
|
+
closeAfterReset: false,
|
26
|
+
closeOnEscape : false,
|
27
|
+
multipleSearch : false,
|
28
|
+
cloneSearchRowOnAdd: true,
|
29
|
+
// translation
|
30
|
+
// if you want to change or remove the order change it in sopt
|
31
|
+
// ['bw','eq','ne','lt','le','gt','ge','ew','cn']
|
32
|
+
sopt: null,
|
33
|
+
// Note: stringResult is intentionally declared "undefined by default".
|
34
|
+
// you are velcome to define stringResult expressly in the options you pass to searchGrid()
|
35
|
+
// stringResult is a "safeguard" measure to insure we post sensible data when communicated as form-encoded
|
36
|
+
// see http://github.com/tonytomov/jqGrid/issues/#issue/36
|
37
|
+
//
|
38
|
+
// If this value is not expressly defined in the incoming options,
|
39
|
+
// lower in the code we will infer the value based on value of multipleSearch
|
40
|
+
stringResult: undefined,
|
41
|
+
onClose : null,
|
42
|
+
// useDataProxy allows ADD, EDIT and DEL code to bypass calling $.ajax
|
43
|
+
// directly when grid's 'dataProxy' property (grid.p.dataProxy) is a function.
|
44
|
+
// Used for "editGridRow" and "delGridRow" below and automatically flipped to TRUE
|
45
|
+
// when ajax setting's 'url' (grid's 'editurl') property is undefined.
|
46
|
+
// When 'useDataProxy' is true, instead of calling $.ajax.call(gridDOMobj, o, i) we call
|
47
|
+
// gridDOMobj.p.dataProxy.call(gridDOMobj, o, i)
|
48
|
+
//
|
49
|
+
// Behavior is extremely similar to when 'datatype' is a function, but arguments are slightly different.
|
50
|
+
// Normally the following is fed to datatype.call(a, b, c):
|
51
|
+
// a = Pointer to grid's table DOM element, b = grid.p.postdata, c = "load_"+grid's ID
|
52
|
+
// In cases of "edit" and "del" the following is fed:
|
53
|
+
// a = Pointer to grid's table DOM element (same),
|
54
|
+
// b = extended Ajax Options including postdata in "data" property. (different object type)
|
55
|
+
// c = "set_"+grid's ID in case of "edit" and "del_"+grid's ID in case of "del" (same type, different content)
|
56
|
+
// The major difference is that complete ajax options object, with attached "complete" and "error"
|
57
|
+
// callback functions is fed instead of only post data.
|
58
|
+
// This allows you to emulate a $.ajax call (including calling "complete"/"error"),
|
59
|
+
// while retrieving the data locally in the browser.
|
60
|
+
useDataProxy: false,
|
61
|
+
overlay : true
|
62
|
+
}, $.jgrid.search, p || {});
|
63
|
+
return this.each(function() {
|
64
|
+
var $t = this;
|
65
|
+
if(!$t.grid) {return;}
|
66
|
+
function applyDefaultFilters(gridDOMobj, filterSettings) {
|
67
|
+
/*
|
68
|
+
gridDOMobj = ointer to grid DOM object ( $(#list)[0] )
|
69
|
+
What we need from gridDOMobj:
|
70
|
+
gridDOMobj.SearchFilter is the pointer to the Search box, once it's created.
|
71
|
+
gridDOMobj.p.postData - dictionary of post settings. These can be overriden at grid creation to
|
72
|
+
contain default filter settings. We will parse these and will populate the search with defaults.
|
73
|
+
filterSettings - same settings object you (would) pass to $().jqGrid('searchGrid', filterSettings);
|
74
|
+
*/
|
75
|
+
|
76
|
+
// Pulling default filter settings out of postData property of grid's properties.:
|
77
|
+
var defaultFilters = gridDOMobj.p.postData[filterSettings.sFilter];
|
78
|
+
// example of what we might get: {"groupOp":"and","rules":[{"field":"amount","op":"eq","data":"100"}]}
|
79
|
+
// suppose we have imported this with grid import, the this is a string.
|
80
|
+
if(typeof(defaultFilters) == "string") {
|
81
|
+
defaultFilters = $.jgrid.parse(defaultFilters);
|
82
|
+
}
|
83
|
+
if (defaultFilters) {
|
84
|
+
if (defaultFilters.groupOp) {
|
85
|
+
gridDOMobj.SearchFilter.setGroupOp(defaultFilters.groupOp);
|
86
|
+
}
|
87
|
+
if (defaultFilters.rules) {
|
88
|
+
var f
|
89
|
+
, i = 0
|
90
|
+
, li = defaultFilters.rules.length
|
91
|
+
, success = false;
|
92
|
+
for (; i < li; i++) {
|
93
|
+
f = defaultFilters.rules[i];
|
94
|
+
// we are not trying to counter all issues with filter declaration here. Just the basics to avoid lookup exceptions.
|
95
|
+
if (f.field !== undefined && f.op !== undefined && f.data !== undefined) {
|
96
|
+
success = gridDOMobj.SearchFilter.setFilter({
|
97
|
+
'sfref':gridDOMobj.SearchFilter.$.find(".sf:last"),
|
98
|
+
'filter':$.extend({},f)
|
99
|
+
});
|
100
|
+
if (success) { gridDOMobj.SearchFilter.add(); }
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
} // end of applyDefaultFilters
|
106
|
+
|
107
|
+
if($.fn.searchFilter) {
|
108
|
+
var fid = "fbox_"+$t.p.id;
|
109
|
+
if(p.recreateFilter===true) {$("#"+fid).remove();}
|
110
|
+
if( $("#"+fid).html() != null ) {
|
111
|
+
if ( $.isFunction(p.beforeShowSearch) ) { p.beforeShowSearch($("#"+fid)); }
|
112
|
+
showFilter();
|
113
|
+
if( $.isFunction(p.afterShowSearch) ) { p.afterShowSearch($("#"+fid)); }
|
114
|
+
} else {
|
115
|
+
var fields = [],
|
116
|
+
colNames = $("#"+$t.p.id).jqGrid("getGridParam","colNames"),
|
117
|
+
colModel = $("#"+$t.p.id).jqGrid("getGridParam","colModel"),
|
118
|
+
stempl = ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc'],
|
119
|
+
j,pos,k,oprtr=[];
|
120
|
+
if (p.sopt !==null) {
|
121
|
+
k=0;
|
122
|
+
for(j=0;j<p.sopt.length;j++) {
|
123
|
+
if( (pos= $.inArray(p.sopt[j],stempl)) != -1 ){
|
124
|
+
oprtr[k] = {op:p.sopt[j],text: p.odata[pos]};
|
125
|
+
k++;
|
126
|
+
}
|
127
|
+
}
|
128
|
+
} else {
|
129
|
+
for(j=0;j<stempl.length;j++) {
|
130
|
+
oprtr[j] = {op:stempl[j],text: p.odata[j]};
|
131
|
+
}
|
132
|
+
}
|
133
|
+
var searchable;
|
134
|
+
$.each(colModel, function(i, v) {
|
135
|
+
var searchable = (typeof v.search === 'undefined') ? true: v.search ,
|
136
|
+
hidden = (v.hidden === true),
|
137
|
+
soptions = $.extend({}, {text: colNames[i], itemval: v.index || v.name}, this.searchoptions),
|
138
|
+
ignoreHiding = (soptions.searchhidden === true);
|
139
|
+
if(typeof soptions.sopt !== 'undefined') {
|
140
|
+
k=0;
|
141
|
+
soptions.ops =[];
|
142
|
+
if(soptions.sopt.length>0) {
|
143
|
+
for(j=0;j<soptions.sopt.length;j++) {
|
144
|
+
if( (pos= $.inArray(soptions.sopt[j],stempl)) != -1 ){
|
145
|
+
soptions.ops[k] = {op:soptions.sopt[j],text: p.odata[pos]};
|
146
|
+
k++;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
if(typeof(this.stype) === 'undefined') { this.stype='text'; }
|
152
|
+
if(this.stype == 'select') {
|
153
|
+
if ( soptions.dataUrl !== undefined) {}
|
154
|
+
else {
|
155
|
+
var eov;
|
156
|
+
if(soptions.value) {
|
157
|
+
eov = soptions.value;
|
158
|
+
} else if(this.editoptions) {
|
159
|
+
eov = this.editoptions.value;
|
160
|
+
}
|
161
|
+
if(eov) {
|
162
|
+
soptions.dataValues =[];
|
163
|
+
if(typeof(eov) === 'string') {
|
164
|
+
var so = eov.split(";"),sv;
|
165
|
+
for(j=0;j<so.length;j++) {
|
166
|
+
sv = so[j].split(":");
|
167
|
+
soptions.dataValues[j] ={value:sv[0],text:sv[1]};
|
168
|
+
}
|
169
|
+
} else if (typeof(eov) === 'object') {
|
170
|
+
j=0;
|
171
|
+
for (var key in eov) {
|
172
|
+
if(eov.hasOwnProperty(key)) {
|
173
|
+
soptions.dataValues[j] ={value:key,text:eov[key]};
|
174
|
+
j++;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
}
|
180
|
+
}
|
181
|
+
if ((ignoreHiding && searchable) || (searchable && !hidden)) {
|
182
|
+
fields.push(soptions);
|
183
|
+
}
|
184
|
+
});
|
185
|
+
if(fields.length>0){
|
186
|
+
$("<div id='"+fid+"' role='dialog' tabindex='-1'></div>").insertBefore("#gview_"+$t.p.id);
|
187
|
+
// Before we create searchFilter we need to decide if we want to get back a string or a JS object.
|
188
|
+
// see http://github.com/tonytomov/jqGrid/issues/#issue/36 for background on the issue.
|
189
|
+
// If p.stringResult is defined, it was explisitly passed to us by user. Honor the choice, whatever it is.
|
190
|
+
if (p.stringResult===undefined) {
|
191
|
+
// to provide backward compatibility, inferring stringResult value from multipleSearch
|
192
|
+
p.stringResult = p.multipleSearch;
|
193
|
+
}
|
194
|
+
// we preserve the return value here to retain access to .add() and other good methods of search form.
|
195
|
+
$t.SearchFilter = $("#"+fid).searchFilter(fields, { groupOps: p.groupOps, operators: oprtr, onClose:hideFilter, resetText: p.Reset, searchText: p.Find, windowTitle: p.caption, rulesText:p.rulesText, matchText:p.matchText, onSearch: searchFilters, onReset: resetFilters,stringResult:p.stringResult, ajaxSelectOptions: $.extend({},$.jgrid.ajaxOptions,$t.p.ajaxSelectOptions ||{}), clone: p.cloneSearchRowOnAdd });
|
196
|
+
$(".ui-widget-overlay","#"+fid).remove();
|
197
|
+
if($t.p.direction=="rtl") { $(".ui-closer","#"+fid).css("float","left"); }
|
198
|
+
if (p.drag===true) {
|
199
|
+
$("#"+fid+" table thead tr:first td:first").css('cursor','move');
|
200
|
+
if(jQuery.fn.jqDrag) {
|
201
|
+
$("#"+fid).jqDrag($("#"+fid+" table thead tr:first td:first"));
|
202
|
+
} else {
|
203
|
+
try {
|
204
|
+
$("#"+fid).draggable({handle: $("#"+fid+" table thead tr:first td:first")});
|
205
|
+
} catch (e) {}
|
206
|
+
}
|
207
|
+
}
|
208
|
+
if(p.multipleSearch === false) {
|
209
|
+
$(".ui-del, .ui-add, .ui-del, .ui-add-last, .matchText, .rulesText", "#"+fid).hide();
|
210
|
+
$("select[name='groupOp']","#"+fid).hide();
|
211
|
+
}
|
212
|
+
if (p.multipleSearch === true && p.loadDefaults === true) {
|
213
|
+
applyDefaultFilters($t, p);
|
214
|
+
}
|
215
|
+
if ( $.isFunction(p.onInitializeSearch) ) { p.onInitializeSearch( $("#"+fid) ); }
|
216
|
+
if ( $.isFunction(p.beforeShowSearch) ) { p.beforeShowSearch($("#"+fid)); }
|
217
|
+
showFilter();
|
218
|
+
if( $.isFunction(p.afterShowSearch) ) { p.afterShowSearch($("#"+fid)); }
|
219
|
+
if(p.closeOnEscape===true){
|
220
|
+
$("#"+fid).keydown( function( e ) {
|
221
|
+
if( e.which == 27 ) {
|
222
|
+
hideFilter($("#"+fid));
|
223
|
+
}
|
224
|
+
});
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}
|
228
|
+
}
|
229
|
+
function searchFilters(filters) {
|
230
|
+
var hasFilters = (filters !== undefined),
|
231
|
+
grid = $("#"+$t.p.id), sdata={};
|
232
|
+
if(p.multipleSearch===false) {
|
233
|
+
sdata[p.sField] = filters.rules[0].field;
|
234
|
+
sdata[p.sValue] = filters.rules[0].data;
|
235
|
+
sdata[p.sOper] = filters.rules[0].op;
|
236
|
+
} else {
|
237
|
+
sdata[p.sFilter] = filters;
|
238
|
+
}
|
239
|
+
grid[0].p.search = hasFilters;
|
240
|
+
$.extend(grid[0].p.postData,sdata);
|
241
|
+
grid.trigger("reloadGrid",[{page:1}]);
|
242
|
+
if(p.closeAfterSearch) { hideFilter($("#"+fid)); }
|
243
|
+
}
|
244
|
+
function resetFilters(op) {
|
245
|
+
var reload = op && op.hasOwnProperty("reload") ? op.reload : true;
|
246
|
+
grid = $("#"+$t.p.id), sdata=[];
|
247
|
+
grid[0].p.search = false;
|
248
|
+
if(p.multipleSearch===false) {
|
249
|
+
sdata[p.sField] = sdata[p.sValue] = sdata[p.sOper] = "";
|
250
|
+
} else {
|
251
|
+
sdata[p.sFilter] = "";
|
252
|
+
}
|
253
|
+
$.extend(grid[0].p.postData,sdata);
|
254
|
+
if(reload) {
|
255
|
+
grid.trigger("reloadGrid",[{page:1}]);
|
256
|
+
}
|
257
|
+
if(p.closeAfterReset) { hideFilter($("#"+fid)); }
|
258
|
+
}
|
259
|
+
function hideFilter(selector) {
|
260
|
+
if(p.onClose){
|
261
|
+
var fclm = p.onClose(selector);
|
262
|
+
if(typeof fclm == 'boolean' && !fclm) { return; }
|
263
|
+
}
|
264
|
+
selector.hide();
|
265
|
+
if(p.overlay === true) {
|
266
|
+
$(".jqgrid-overlay:first","#gbox_"+$t.p.id).hide();
|
267
|
+
}
|
268
|
+
}
|
269
|
+
function showFilter(){
|
270
|
+
var fl = $(".ui-searchFilter").length;
|
271
|
+
if(fl > 1) {
|
272
|
+
var zI = $("#"+fid).css("zIndex");
|
273
|
+
$("#"+fid).css({zIndex:parseInt(zI,10)+fl});
|
274
|
+
}
|
275
|
+
$("#"+fid).show();
|
276
|
+
if(p.overlay === true) {
|
277
|
+
$(".jqgrid-overlay:first","#gbox_"+$t.p.id).show();
|
278
|
+
}
|
279
|
+
try{$(':input:visible',"#"+fid)[0].focus();}catch(_){}
|
280
|
+
}
|
281
|
+
});
|
282
|
+
},
|
283
|
+
editGridRow : function(rowid, p){
|
284
|
+
p = $.extend({
|
285
|
+
top : 0,
|
286
|
+
left: 0,
|
287
|
+
width: 300,
|
288
|
+
height: 'auto',
|
289
|
+
dataheight: 'auto',
|
290
|
+
modal: false,
|
291
|
+
drag: true,
|
292
|
+
resize: true,
|
293
|
+
url: null,
|
294
|
+
mtype : "POST",
|
295
|
+
clearAfterAdd :true,
|
296
|
+
closeAfterEdit : false,
|
297
|
+
reloadAfterSubmit : true,
|
298
|
+
onInitializeForm: null,
|
299
|
+
beforeInitData: null,
|
300
|
+
beforeShowForm: null,
|
301
|
+
afterShowForm: null,
|
302
|
+
beforeSubmit: null,
|
303
|
+
afterSubmit: null,
|
304
|
+
onclickSubmit: null,
|
305
|
+
afterComplete: null,
|
306
|
+
onclickPgButtons : null,
|
307
|
+
afterclickPgButtons: null,
|
308
|
+
editData : {},
|
309
|
+
recreateForm : false,
|
310
|
+
jqModal : true,
|
311
|
+
closeOnEscape : false,
|
312
|
+
addedrow : "first",
|
313
|
+
topinfo : '',
|
314
|
+
bottominfo: '',
|
315
|
+
saveicon : [],
|
316
|
+
closeicon : [],
|
317
|
+
savekey: [false,13],
|
318
|
+
navkeys: [false,38,40],
|
319
|
+
checkOnSubmit : false,
|
320
|
+
checkOnUpdate : false,
|
321
|
+
_savedData : {},
|
322
|
+
processing : false,
|
323
|
+
onClose : null,
|
324
|
+
ajaxEditOptions : {},
|
325
|
+
serializeEditData : null,
|
326
|
+
viewPagerButtons : true
|
327
|
+
}, $.jgrid.edit, p || {});
|
328
|
+
rp_ge = p;
|
329
|
+
return this.each(function(){
|
330
|
+
var $t = this;
|
331
|
+
if (!$t.grid || !rowid) { return; }
|
332
|
+
var gID = $t.p.id,
|
333
|
+
frmgr = "FrmGrid_"+gID,frmtb = "TblGrid_"+gID,
|
334
|
+
IDs = {themodal:'editmod'+gID,modalhead:'edithd'+gID,modalcontent:'editcnt'+gID, scrollelm : frmgr},
|
335
|
+
onBeforeShow = $.isFunction(rp_ge.beforeShowForm) ? rp_ge.beforeShowForm : false,
|
336
|
+
onAfterShow = $.isFunction(rp_ge.afterShowForm) ? rp_ge.afterShowForm : false,
|
337
|
+
onBeforeInit = $.isFunction(rp_ge.beforeInitData) ? rp_ge.beforeInitData : false,
|
338
|
+
onInitializeForm = $.isFunction(rp_ge.onInitializeForm) ? rp_ge.onInitializeForm : false,
|
339
|
+
copydata = null,
|
340
|
+
maxCols = 1, maxRows=0, gurl, postdata, ret, extpost, newData, diff;
|
341
|
+
if (rowid=="new") {
|
342
|
+
rowid = "_empty";
|
343
|
+
p.caption=p.addCaption;
|
344
|
+
} else {
|
345
|
+
p.caption=p.editCaption;
|
346
|
+
}
|
347
|
+
if(p.recreateForm===true && $("#"+IDs.themodal).html() != null) {
|
348
|
+
$("#"+IDs.themodal).remove();
|
349
|
+
}
|
350
|
+
var closeovrl = true;
|
351
|
+
if(p.checkOnUpdate && p.jqModal && !p.modal) {
|
352
|
+
closeovrl = false;
|
353
|
+
}
|
354
|
+
if ( $("#"+IDs.themodal).html() != null ) {
|
355
|
+
$(".ui-jqdialog-title","#"+IDs.modalhead).html(p.caption);
|
356
|
+
$("#FormError","#"+frmtb).hide();
|
357
|
+
if(rp_ge.topinfo) {
|
358
|
+
$(".topinfo","#"+frmtb+"_2").html(rp_ge.topinfo);
|
359
|
+
$(".tinfo","#"+frmtb+"_2").show();
|
360
|
+
} else {
|
361
|
+
$(".tinfo","#"+frmtb+"_2").hide();
|
362
|
+
}
|
363
|
+
if(rp_ge.bottominfo) {
|
364
|
+
$(".bottominfo","#"+frmtb+"_2").html(rp_ge.bottominfo);
|
365
|
+
$(".binfo","#"+frmtb+"_2").show();
|
366
|
+
} else {
|
367
|
+
$(".binfo","#"+frmtb+"_2").hide();
|
368
|
+
}
|
369
|
+
if(onBeforeInit) { onBeforeInit($("#"+frmgr)); }
|
370
|
+
// filldata
|
371
|
+
fillData(rowid,$t,frmgr);
|
372
|
+
///
|
373
|
+
if(rowid=="_empty" || !rp_ge.viewPagerButtons) {
|
374
|
+
$("#pData, #nData","#"+frmtb+"_2").hide();
|
375
|
+
} else {
|
376
|
+
$("#pData, #nData","#"+frmtb+"_2").show();
|
377
|
+
}
|
378
|
+
if(rp_ge.processing===true) {
|
379
|
+
rp_ge.processing=false;
|
380
|
+
$("#sData", "#"+frmtb+"_2").removeClass('ui-state-active');
|
381
|
+
}
|
382
|
+
if($("#"+frmgr).data("disabled")===true) {
|
383
|
+
$(".confirm","#"+IDs.themodal).hide();
|
384
|
+
$("#"+frmgr).data("disabled",false);
|
385
|
+
}
|
386
|
+
if(onBeforeShow) { onBeforeShow($("#"+frmgr)); }
|
387
|
+
$("#"+IDs.themodal).data("onClose",rp_ge.onClose);
|
388
|
+
viewModal("#"+IDs.themodal,{gbox:"#gbox_"+gID,jqm:p.jqModal, jqM: false, closeoverlay: closeovrl, modal:p.modal});
|
389
|
+
if(!closeovrl) {
|
390
|
+
$(".jqmOverlay").click(function(){
|
391
|
+
if(!checkUpdates()) { return false; }
|
392
|
+
hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal, onClose: rp_ge.onClose});
|
393
|
+
return false;
|
394
|
+
});
|
395
|
+
}
|
396
|
+
if(onAfterShow) { onAfterShow($("#"+frmgr)); }
|
397
|
+
} else {
|
398
|
+
$($t.p.colModel).each( function(i) {
|
399
|
+
var fmto = this.formoptions;
|
400
|
+
maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 );
|
401
|
+
maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 );
|
402
|
+
});
|
403
|
+
var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px";
|
404
|
+
var flr, frm = $("<form name='FormPost' id='"+frmgr+"' class='FormGrid' onSubmit='return false;' style='width:100%;overflow:auto;position:relative;height:"+dh+";'></form>").data("disabled",false),
|
405
|
+
tbl =$("<table id='"+frmtb+"' class='EditTable' cellspacing='0' cellpading='0' border='0'><tbody></tbody></table>");
|
406
|
+
$(frm).append(tbl);
|
407
|
+
flr = $("<tr id='FormError' style='display:none'><td class='ui-state-error' colspan='"+(maxCols*2)+"'></td></tr>");
|
408
|
+
flr[0].rp = 0;
|
409
|
+
$(tbl).append(flr);
|
410
|
+
//topinfo
|
411
|
+
flr = $("<tr style='display:none' class='tinfo'><td class='topinfo' colspan='"+(maxCols*2)+"'>"+rp_ge.topinfo+"</td></tr>");
|
412
|
+
flr[0].rp = 0;
|
413
|
+
$(tbl).append(flr);
|
414
|
+
// set the id.
|
415
|
+
// use carefull only to change here colproperties.
|
416
|
+
if(onBeforeInit) { onBeforeInit($("#"+frmgr)); }
|
417
|
+
// create data
|
418
|
+
var rtlb = $t.p.direction == "rtl" ? true :false,
|
419
|
+
bp = rtlb ? "nData" : "pData",
|
420
|
+
bn = rtlb ? "pData" : "nData",
|
421
|
+
valref = createData(rowid,$t,tbl,maxCols),
|
422
|
+
// buttons at footer
|
423
|
+
bP = "<a href='javascript:void(0)' id='"+bp+"' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></div>",
|
424
|
+
bN = "<a href='javascript:void(0)' id='"+bn+"' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></div>",
|
425
|
+
bS ="<a href='javascript:void(0)' id='sData' class='fm-button ui-state-default ui-corner-all'>"+p.bSubmit+"</a>",
|
426
|
+
bC ="<a href='javascript:void(0)' id='cData' class='fm-button ui-state-default ui-corner-all'>"+p.bCancel+"</a>";
|
427
|
+
var bt = "<table border='0' class='EditTable' id='"+frmtb+"_2'><tbody><tr id='Act_Buttons'><td class='navButton ui-widget-content'>"+(rtlb ? bN+bP : bP+bN)+"</td><td class='EditButton ui-widget-content'>"+bS+bC+"</td></tr>";
|
428
|
+
bt += "<tr style='display:none' class='binfo'><td class='bottominfo' colspan='2'>"+rp_ge.bottominfo+"</td></tr>";
|
429
|
+
bt += "</tbody></table>";
|
430
|
+
if(maxRows > 0) {
|
431
|
+
var sd=[];
|
432
|
+
$.each($(tbl)[0].rows,function(i,r){
|
433
|
+
sd[i] = r;
|
434
|
+
});
|
435
|
+
sd.sort(function(a,b){
|
436
|
+
if(a.rp > b.rp) {return 1;}
|
437
|
+
if(a.rp < b.rp) {return -1;}
|
438
|
+
return 0;
|
439
|
+
});
|
440
|
+
$.each(sd, function(index, row) {
|
441
|
+
$('tbody',tbl).append(row);
|
442
|
+
});
|
443
|
+
}
|
444
|
+
p.gbox = "#gbox_"+gID;
|
445
|
+
var cle = false;
|
446
|
+
if(p.closeOnEscape===true){
|
447
|
+
p.closeOnEscape = false;
|
448
|
+
cle = true;
|
449
|
+
}
|
450
|
+
var tms = $("<span></span>").append(frm).append(bt);
|
451
|
+
createModal(IDs,tms,p,"#gview_"+$t.p.id,$("#gbox_"+$t.p.id)[0]);
|
452
|
+
if(rtlb) {
|
453
|
+
$("#pData, #nData","#"+frmtb+"_2").css("float","right");
|
454
|
+
$(".EditButton","#"+frmtb+"_2").css("text-align","left");
|
455
|
+
}
|
456
|
+
if(rp_ge.topinfo) { $(".tinfo","#"+frmtb+"_2").show(); }
|
457
|
+
if(rp_ge.bottominfo) { $(".binfo","#"+frmtb+"_2").show(); }
|
458
|
+
tms = null; bt=null;
|
459
|
+
$("#"+IDs.themodal).keydown( function( e ) {
|
460
|
+
var wkey = e.target;
|
461
|
+
if ($("#"+frmgr).data("disabled")===true ) { return false; }//??
|
462
|
+
if(rp_ge.savekey[0] === true && e.which == rp_ge.savekey[1]) { // save
|
463
|
+
if(wkey.tagName != "TEXTAREA") {
|
464
|
+
$("#sData", "#"+frmtb+"_2").trigger("click");
|
465
|
+
return false;
|
466
|
+
}
|
467
|
+
}
|
468
|
+
if(e.which === 27) {
|
469
|
+
if(!checkUpdates()) { return false; }
|
470
|
+
if(cle) { hideModal(this,{gb:p.gbox,jqm:p.jqModal, onClose: rp_ge.onClose}); }
|
471
|
+
return false;
|
472
|
+
}
|
473
|
+
if(rp_ge.navkeys[0]===true) {
|
474
|
+
if($("#id_g","#"+frmtb).val() == "_empty") { return true; }
|
475
|
+
if(e.which == rp_ge.navkeys[1]){ //up
|
476
|
+
$("#pData", "#"+frmtb+"_2").trigger("click");
|
477
|
+
return false;
|
478
|
+
}
|
479
|
+
if(e.which == rp_ge.navkeys[2]){ //down
|
480
|
+
$("#nData", "#"+frmtb+"_2").trigger("click");
|
481
|
+
return false;
|
482
|
+
}
|
483
|
+
}
|
484
|
+
});
|
485
|
+
if(p.checkOnUpdate) {
|
486
|
+
$("a.ui-jqdialog-titlebar-close span","#"+IDs.themodal).removeClass("jqmClose");
|
487
|
+
$("a.ui-jqdialog-titlebar-close","#"+IDs.themodal).unbind("click")
|
488
|
+
.click(function(){
|
489
|
+
if(!checkUpdates()) { return false; }
|
490
|
+
hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal,onClose: rp_ge.onClose});
|
491
|
+
return false;
|
492
|
+
});
|
493
|
+
}
|
494
|
+
p.saveicon = $.extend([true,"left","ui-icon-disk"],p.saveicon);
|
495
|
+
p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon);
|
496
|
+
// beforeinitdata after creation of the form
|
497
|
+
if(p.saveicon[0]===true) {
|
498
|
+
$("#sData","#"+frmtb+"_2").addClass(p.saveicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
|
499
|
+
.append("<span class='ui-icon "+p.saveicon[2]+"'></span>");
|
500
|
+
}
|
501
|
+
if(p.closeicon[0]===true) {
|
502
|
+
$("#cData","#"+frmtb+"_2").addClass(p.closeicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
|
503
|
+
.append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
|
504
|
+
}
|
505
|
+
if(rp_ge.checkOnSubmit || rp_ge.checkOnUpdate) {
|
506
|
+
bS ="<a href='javascript:void(0)' id='sNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bYes+"</a>";
|
507
|
+
bN ="<a href='javascript:void(0)' id='nNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bNo+"</a>";
|
508
|
+
bC ="<a href='javascript:void(0)' id='cNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bExit+"</a>";
|
509
|
+
var ii, zI = p.zIndex || 999; zI ++;
|
510
|
+
if ($.browser.msie && $.browser.version ==6) {
|
511
|
+
ii = '<iframe style="display:block;position:absolute;z-index:-1;filter:Alpha(Opacity=\'0\');" src="javascript:false;"></iframe>';
|
512
|
+
} else { ii="";}
|
513
|
+
$("<div class='ui-widget-overlay jqgrid-overlay confirm' style='z-index:"+zI+";display:none;'> "+ii+"</div><div class='confirm ui-widget-content ui-jqconfirm' style='z-index:"+(zI+1)+"'>"+p.saveData+"<br/><br/>"+bS+bN+bC+"</div>").insertAfter("#"+frmgr);
|
514
|
+
$("#sNew","#"+IDs.themodal).click(function(){
|
515
|
+
postIt();
|
516
|
+
$("#"+frmgr).data("disabled",false);
|
517
|
+
$(".confirm","#"+IDs.themodal).hide();
|
518
|
+
return false;
|
519
|
+
});
|
520
|
+
$("#nNew","#"+IDs.themodal).click(function(){
|
521
|
+
$(".confirm","#"+IDs.themodal).hide();
|
522
|
+
$("#"+frmgr).data("disabled",false);
|
523
|
+
setTimeout(function(){$(":input","#"+frmgr)[0].focus();},0);
|
524
|
+
return false;
|
525
|
+
});
|
526
|
+
$("#cNew","#"+IDs.themodal).click(function(){
|
527
|
+
$(".confirm","#"+IDs.themodal).hide();
|
528
|
+
$("#"+frmgr).data("disabled",false);
|
529
|
+
hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal,onClose: rp_ge.onClose});
|
530
|
+
return false;
|
531
|
+
});
|
532
|
+
}
|
533
|
+
// here initform - only once
|
534
|
+
if(onInitializeForm) { onInitializeForm($("#"+frmgr)); }
|
535
|
+
if(rowid=="_empty" || !rp_ge.viewPagerButtons) { $("#pData,#nData","#"+frmtb+"_2").hide(); } else { $("#pData,#nData","#"+frmtb+"_2").show(); }
|
536
|
+
if(onBeforeShow) { onBeforeShow($("#"+frmgr)); }
|
537
|
+
$("#"+IDs.themodal).data("onClose",rp_ge.onClose);
|
538
|
+
viewModal("#"+IDs.themodal,{gbox:"#gbox_"+gID,jqm:p.jqModal,closeoverlay:closeovrl,modal:p.modal});
|
539
|
+
if(!closeovrl) {
|
540
|
+
$(".jqmOverlay").click(function(){
|
541
|
+
if(!checkUpdates()) { return false; }
|
542
|
+
hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal, onClose: rp_ge.onClose});
|
543
|
+
return false;
|
544
|
+
});
|
545
|
+
}
|
546
|
+
if(onAfterShow) { onAfterShow($("#"+frmgr)); }
|
547
|
+
$(".fm-button","#"+IDs.themodal).hover(
|
548
|
+
function(){$(this).addClass('ui-state-hover');},
|
549
|
+
function(){$(this).removeClass('ui-state-hover');}
|
550
|
+
);
|
551
|
+
$("#sData", "#"+frmtb+"_2").click(function(e){
|
552
|
+
postdata = {}; extpost={};
|
553
|
+
$("#FormError","#"+frmtb).hide();
|
554
|
+
// all depend on ret array
|
555
|
+
//ret[0] - succes
|
556
|
+
//ret[1] - msg if not succes
|
557
|
+
//ret[2] - the id that will be set if reload after submit false
|
558
|
+
getFormData();
|
559
|
+
if(postdata[$t.p.id+"_id"] == "_empty") { postIt(); }
|
560
|
+
else if(p.checkOnSubmit===true ) {
|
561
|
+
newData = $.extend({},postdata,extpost);
|
562
|
+
diff = compareData(newData,rp_ge._savedData);
|
563
|
+
if(diff) {
|
564
|
+
$("#"+frmgr).data("disabled",true);
|
565
|
+
$(".confirm","#"+IDs.themodal).show();
|
566
|
+
} else {
|
567
|
+
postIt();
|
568
|
+
}
|
569
|
+
} else {
|
570
|
+
postIt();
|
571
|
+
}
|
572
|
+
return false;
|
573
|
+
});
|
574
|
+
$("#cData", "#"+frmtb+"_2").click(function(e){
|
575
|
+
if(!checkUpdates()) { return false; }
|
576
|
+
hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal,onClose: rp_ge.onClose});
|
577
|
+
return false;
|
578
|
+
});
|
579
|
+
$("#nData", "#"+frmtb+"_2").click(function(e){
|
580
|
+
if(!checkUpdates()) { return false; }
|
581
|
+
$("#FormError","#"+frmtb).hide();
|
582
|
+
var npos = getCurrPos();
|
583
|
+
npos[0] = parseInt(npos[0],10);
|
584
|
+
if(npos[0] != -1 && npos[1][npos[0]+1]) {
|
585
|
+
if($.isFunction(p.onclickPgButtons)) {
|
586
|
+
p.onclickPgButtons('next',$("#"+frmgr),npos[1][npos[0]]);
|
587
|
+
}
|
588
|
+
fillData(npos[1][npos[0]+1],$t,frmgr);
|
589
|
+
$($t).jqGrid("setSelection",npos[1][npos[0]+1]);
|
590
|
+
if($.isFunction(p.afterclickPgButtons)) {
|
591
|
+
p.afterclickPgButtons('next',$("#"+frmgr),npos[1][npos[0]+1]);
|
592
|
+
}
|
593
|
+
updateNav(npos[0]+1,npos[1].length-1);
|
594
|
+
}
|
595
|
+
return false;
|
596
|
+
});
|
597
|
+
$("#pData", "#"+frmtb+"_2").click(function(e){
|
598
|
+
if(!checkUpdates()) { return false; }
|
599
|
+
$("#FormError","#"+frmtb).hide();
|
600
|
+
var ppos = getCurrPos();
|
601
|
+
if(ppos[0] != -1 && ppos[1][ppos[0]-1]) {
|
602
|
+
if($.isFunction(p.onclickPgButtons)) {
|
603
|
+
p.onclickPgButtons('prev',$("#"+frmgr),ppos[1][ppos[0]]);
|
604
|
+
}
|
605
|
+
fillData(ppos[1][ppos[0]-1],$t,frmgr);
|
606
|
+
$($t).jqGrid("setSelection",ppos[1][ppos[0]-1]);
|
607
|
+
if($.isFunction(p.afterclickPgButtons)) {
|
608
|
+
p.afterclickPgButtons('prev',$("#"+frmgr),ppos[1][ppos[0]-1]);
|
609
|
+
}
|
610
|
+
updateNav(ppos[0]-1,ppos[1].length-1);
|
611
|
+
}
|
612
|
+
return false;
|
613
|
+
});
|
614
|
+
}
|
615
|
+
var posInit =getCurrPos();
|
616
|
+
updateNav(posInit[0],posInit[1].length-1);
|
617
|
+
function updateNav(cr,totr,rid){
|
618
|
+
if (cr===0) { $("#pData","#"+frmtb+"_2").addClass('ui-state-disabled'); } else { $("#pData","#"+frmtb+"_2").removeClass('ui-state-disabled'); }
|
619
|
+
if (cr==totr) { $("#nData","#"+frmtb+"_2").addClass('ui-state-disabled'); } else { $("#nData","#"+frmtb+"_2").removeClass('ui-state-disabled'); }
|
620
|
+
}
|
621
|
+
function getCurrPos() {
|
622
|
+
var rowsInGrid = $($t).jqGrid("getDataIDs"),
|
623
|
+
selrow = $("#id_g","#"+frmtb).val(),
|
624
|
+
pos = $.inArray(selrow,rowsInGrid);
|
625
|
+
return [pos,rowsInGrid];
|
626
|
+
}
|
627
|
+
function checkUpdates () {
|
628
|
+
var stat = true;
|
629
|
+
$("#FormError","#"+frmtb).hide();
|
630
|
+
if(rp_ge.checkOnUpdate) {
|
631
|
+
postdata = {}; extpost={};
|
632
|
+
getFormData();
|
633
|
+
newData = $.extend({},postdata,extpost);
|
634
|
+
diff = compareData(newData,rp_ge._savedData);
|
635
|
+
if(diff) {
|
636
|
+
$("#"+frmgr).data("disabled",true);
|
637
|
+
$(".confirm","#"+IDs.themodal).show();
|
638
|
+
stat = false;
|
639
|
+
}
|
640
|
+
}
|
641
|
+
return stat;
|
642
|
+
}
|
643
|
+
function getFormData(){
|
644
|
+
$(".FormElement", "#"+frmtb).each(function(i) {
|
645
|
+
var celm = $(".customelement", this);
|
646
|
+
if (celm.length) {
|
647
|
+
var elem = celm[0], nm = $(elem).attr('name');
|
648
|
+
$.each($t.p.colModel, function(i,n){
|
649
|
+
if(this.name == nm && this.editoptions && $.isFunction(this.editoptions.custom_value)) {
|
650
|
+
try {
|
651
|
+
postdata[nm] = this.editoptions.custom_value($("#"+nm,"#"+frmtb),'get');
|
652
|
+
if (postdata[nm] === undefined) { throw "e1"; }
|
653
|
+
} catch (e) {
|
654
|
+
if (e=="e1") { info_dialog(jQuery.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,jQuery.jgrid.edit.bClose);}
|
655
|
+
else { info_dialog(jQuery.jgrid.errors.errcap,e.message,jQuery.jgrid.edit.bClose); }
|
656
|
+
}
|
657
|
+
return true;
|
658
|
+
}
|
659
|
+
});
|
660
|
+
} else {
|
661
|
+
switch ($(this).get(0).type) {
|
662
|
+
case "checkbox":
|
663
|
+
if($(this).attr("checked")) {
|
664
|
+
postdata[this.name]= $(this).val();
|
665
|
+
}else {
|
666
|
+
var ofv = $(this).attr("offval");
|
667
|
+
postdata[this.name]= ofv;
|
668
|
+
}
|
669
|
+
break;
|
670
|
+
case "select-one":
|
671
|
+
postdata[this.name]= $("option:selected",this).val();
|
672
|
+
extpost[this.name]= $("option:selected",this).text();
|
673
|
+
break;
|
674
|
+
case "select-multiple":
|
675
|
+
postdata[this.name]= $(this).val();
|
676
|
+
if(postdata[this.name]) { postdata[this.name] = postdata[this.name].join(","); }
|
677
|
+
else { postdata[this.name] =""; }
|
678
|
+
var selectedText = [];
|
679
|
+
$("option:selected",this).each(
|
680
|
+
function(i,selected){
|
681
|
+
selectedText[i] = $(selected).text();
|
682
|
+
}
|
683
|
+
);
|
684
|
+
extpost[this.name]= selectedText.join(",");
|
685
|
+
break;
|
686
|
+
case "password":
|
687
|
+
case "text":
|
688
|
+
case "textarea":
|
689
|
+
case "button":
|
690
|
+
postdata[this.name] = $(this).val();
|
691
|
+
|
692
|
+
break;
|
693
|
+
}
|
694
|
+
if($t.p.autoencode) { postdata[this.name] = $.jgrid.htmlEncode(postdata[this.name]); }
|
695
|
+
}
|
696
|
+
});
|
697
|
+
return true;
|
698
|
+
}
|
699
|
+
function createData(rowid,obj,tb,maxcols){
|
700
|
+
var nm, hc,trdata, cnt=0,tmp, dc,elc, retpos=[], ind=false,
|
701
|
+
tdtmpl = "<td class='CaptionTD ui-widget-content'> </td><td class='DataTD ui-widget-content' style='white-space:pre'> </td>", tmpl=""; //*2
|
702
|
+
for (var i =1;i<=maxcols;i++) {
|
703
|
+
tmpl += tdtmpl;
|
704
|
+
}
|
705
|
+
if(rowid != '_empty') {
|
706
|
+
ind = $(obj).jqGrid("getInd",rowid);
|
707
|
+
}
|
708
|
+
$(obj.p.colModel).each( function(i) {
|
709
|
+
nm = this.name;
|
710
|
+
// hidden fields are included in the form
|
711
|
+
if(this.editrules && this.editrules.edithidden === true) {
|
712
|
+
hc = false;
|
713
|
+
} else {
|
714
|
+
hc = this.hidden === true ? true : false;
|
715
|
+
}
|
716
|
+
dc = hc ? "style='display:none'" : "";
|
717
|
+
if ( nm !== 'cb' && nm !== 'subgrid' && this.editable===true && nm !== 'rn') {
|
718
|
+
if(ind === false) {
|
719
|
+
tmp = "";
|
720
|
+
} else {
|
721
|
+
if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) {
|
722
|
+
tmp = $("td:eq("+i+")",obj.rows[ind]).text();
|
723
|
+
} else {
|
724
|
+
try {
|
725
|
+
tmp = $.unformat($("td:eq("+i+")",obj.rows[ind]),{rowId:rowid, colModel:this},i);
|
726
|
+
} catch (_) {
|
727
|
+
tmp = $("td:eq("+i+")",obj.rows[ind]).html();
|
728
|
+
}
|
729
|
+
}
|
730
|
+
}
|
731
|
+
var opt = $.extend({}, this.editoptions || {} ,{id:nm,name:nm}),
|
732
|
+
frmopt = $.extend({}, {elmprefix:'',elmsuffix:'',rowabove:false,rowcontent:''}, this.formoptions || {}),
|
733
|
+
rp = parseInt(frmopt.rowpos,10) || cnt+1,
|
734
|
+
cp = parseInt((parseInt(frmopt.colpos,10) || 1)*2,10);
|
735
|
+
if(rowid == "_empty" && opt.defaultValue ) {
|
736
|
+
tmp = $.isFunction(opt.defaultValue) ? opt.defaultValue() : opt.defaultValue;
|
737
|
+
}
|
738
|
+
if(!this.edittype) { this.edittype = "text"; }
|
739
|
+
if($t.p.autoencode) { tmp = $.jgrid.htmlDecode(tmp); }
|
740
|
+
elc = createEl(this.edittype,opt,tmp,false,$.extend({},$.jgrid.ajaxOptions,obj.p.ajaxSelectOptions || {}));
|
741
|
+
if(tmp == "" && this.edittype == "checkbox") {tmp = $(elc).attr("offval");}
|
742
|
+
if(tmp == "" && this.edittype == "select") {tmp = $("option:eq(0)",elc).text();}
|
743
|
+
if(rp_ge.checkOnSubmit || rp_ge.checkOnUpdate) { rp_ge._savedData[nm] = tmp; }
|
744
|
+
$(elc).addClass("FormElement");
|
745
|
+
trdata = $(tb).find("tr[rowpos="+rp+"]");
|
746
|
+
if(frmopt.rowabove) {
|
747
|
+
var newdata = $("<tr><td class='contentinfo' colspan='"+(maxcols*2)+"'>"+frmopt.rowcontent+"</td></tr>");
|
748
|
+
$(tb).append(newdata);
|
749
|
+
newdata[0].rp = rp;
|
750
|
+
}
|
751
|
+
if ( trdata.length===0 ) {
|
752
|
+
trdata = $("<tr "+dc+" rowpos='"+rp+"'></tr>").addClass("FormData").attr("id","tr_"+nm);
|
753
|
+
$(trdata).append(tmpl);
|
754
|
+
$(tb).append(trdata);
|
755
|
+
trdata[0].rp = rp;
|
756
|
+
}
|
757
|
+
$("td:eq("+(cp-2)+")",trdata[0]).html( typeof frmopt.label === 'undefined' ? obj.p.colNames[i]: frmopt.label);
|
758
|
+
$("td:eq("+(cp-1)+")",trdata[0]).append(frmopt.elmprefix).append(elc).append(frmopt.elmsuffix);
|
759
|
+
retpos[cnt] = i;
|
760
|
+
cnt++;
|
761
|
+
}
|
762
|
+
});
|
763
|
+
if( cnt > 0) {
|
764
|
+
var idrow = $("<tr class='FormData' style='display:none'><td class='CaptionTD'></td><td colspan='"+ (maxcols*2-1)+"' class='DataTD'><input class='FormElement' id='id_g' type='text' name='"+obj.p.id+"_id' value='"+rowid+"'/></td></tr>");
|
765
|
+
idrow[0].rp = cnt+999;
|
766
|
+
$(tb).append(idrow);
|
767
|
+
if(rp_ge.checkOnSubmit || rp_ge.checkOnUpdate) { rp_ge._savedData[obj.p.id+"_id"] = rowid; }
|
768
|
+
}
|
769
|
+
return retpos;
|
770
|
+
}
|
771
|
+
function fillData(rowid,obj,fmid){
|
772
|
+
var nm,cnt=0,tmp, fld,opt,vl,vlc;
|
773
|
+
if(rp_ge.checkOnSubmit || rp_ge.checkOnUpdate) {rp_ge._savedData = {};rp_ge._savedData[obj.p.id+"_id"]=rowid;}
|
774
|
+
var cm = obj.p.colModel;
|
775
|
+
if(rowid == '_empty') {
|
776
|
+
$(cm).each(function(i){
|
777
|
+
nm = this.name;
|
778
|
+
opt = $.extend({}, this.editoptions || {} );
|
779
|
+
fld = $("#"+$.jgrid.jqID(nm),"#"+fmid);
|
780
|
+
if(fld[0] != null) {
|
781
|
+
vl = "";
|
782
|
+
if(opt.defaultValue ) {
|
783
|
+
vl = $.isFunction(opt.defaultValue) ? opt.defaultValue() : opt.defaultValue;
|
784
|
+
if(fld[0].type=='checkbox') {
|
785
|
+
vlc = vl.toLowerCase();
|
786
|
+
if(vlc.search(/(false|0|no|off|undefined)/i)<0 && vlc!=="") {
|
787
|
+
fld[0].checked = true;
|
788
|
+
fld[0].defaultChecked = true;
|
789
|
+
fld[0].value = vl;
|
790
|
+
} else {
|
791
|
+
fld.attr({checked:"",defaultChecked:""});
|
792
|
+
}
|
793
|
+
} else {fld.val(vl); }
|
794
|
+
} else {
|
795
|
+
if( fld[0].type=='checkbox' ) {
|
796
|
+
fld[0].checked = false;
|
797
|
+
fld[0].defaultChecked = false;
|
798
|
+
vl = $(fld).attr("offval");
|
799
|
+
} else if (fld[0].type && fld[0].type.substr(0,6)=='select') {
|
800
|
+
fld[0].selectedIndex = 0;
|
801
|
+
} else {
|
802
|
+
fld.val(vl);
|
803
|
+
}
|
804
|
+
}
|
805
|
+
if(rp_ge.checkOnSubmit===true || rp_ge.checkOnUpdate) { rp_ge._savedData[nm] = vl; }
|
806
|
+
}
|
807
|
+
});
|
808
|
+
$("#id_g","#"+fmid).val(rowid);
|
809
|
+
return;
|
810
|
+
}
|
811
|
+
var tre = $(obj).jqGrid("getInd",rowid,true);
|
812
|
+
if(!tre) { return; }
|
813
|
+
$('td',tre).each( function(i) {
|
814
|
+
nm = cm[i].name;
|
815
|
+
// hidden fields are included in the form
|
816
|
+
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn' && cm[i].editable===true) {
|
817
|
+
if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) {
|
818
|
+
tmp = $(this).text();
|
819
|
+
} else {
|
820
|
+
try {
|
821
|
+
tmp = $.unformat(this,{rowId:rowid, colModel:cm[i]},i);
|
822
|
+
} catch (_) {
|
823
|
+
tmp = $(this).html();
|
824
|
+
}
|
825
|
+
}
|
826
|
+
if($t.p.autoencode) { tmp = $.jgrid.htmlDecode(tmp); }
|
827
|
+
if(rp_ge.checkOnSubmit===true || rp_ge.checkOnUpdate) { rp_ge._savedData[nm] = tmp; }
|
828
|
+
nm = $.jgrid.jqID(nm);
|
829
|
+
switch (cm[i].edittype) {
|
830
|
+
case "password":
|
831
|
+
case "text":
|
832
|
+
case "button" :
|
833
|
+
case "image":
|
834
|
+
$("#"+nm,"#"+fmid).val(tmp);
|
835
|
+
break;
|
836
|
+
case "textarea":
|
837
|
+
if(tmp == " " || tmp == " " || (tmp.length==1 && tmp.charCodeAt(0)==160) ) {tmp='';}
|
838
|
+
$("#"+nm,"#"+fmid).val(tmp);
|
839
|
+
break;
|
840
|
+
case "select":
|
841
|
+
var opv = tmp.split(",");
|
842
|
+
opv = $.map(opv,function(n){return $.trim(n);});
|
843
|
+
$("#"+nm+" option","#"+fmid).each(function(j){
|
844
|
+
if (!cm[i].editoptions.multiple && (opv[0] == $.trim($(this).text()) || opv[0] == $.trim($(this).val())) ){
|
845
|
+
this.selected= true;
|
846
|
+
} else if (cm[i].editoptions.multiple){
|
847
|
+
if( $.inArray($.trim($(this).text()), opv ) > -1 || $.inArray($.trim($(this).val()), opv ) > -1 ){
|
848
|
+
this.selected = true;
|
849
|
+
}else{
|
850
|
+
this.selected = false;
|
851
|
+
}
|
852
|
+
} else {
|
853
|
+
this.selected = false;
|
854
|
+
}
|
855
|
+
});
|
856
|
+
break;
|
857
|
+
case "checkbox":
|
858
|
+
tmp = tmp+"";
|
859
|
+
if(cm[i].editoptions && cm[i].editoptions.value) {
|
860
|
+
var cb = cm[i].editoptions.value.split(":");
|
861
|
+
if(cb[0] == tmp) {
|
862
|
+
$("#"+nm,"#"+fmid).attr("checked",true);
|
863
|
+
$("#"+nm,"#"+fmid).attr("defaultChecked",true); //ie
|
864
|
+
} else {
|
865
|
+
$("#"+nm,"#"+fmid).attr("checked",false);
|
866
|
+
$("#"+nm,"#"+fmid).attr("defaultChecked",""); //ie
|
867
|
+
}
|
868
|
+
} else {
|
869
|
+
tmp = tmp.toLowerCase();
|
870
|
+
if(tmp.search(/(false|0|no|off|undefined)/i)<0 && tmp!=="") {
|
871
|
+
$("#"+nm,"#"+fmid).attr("checked",true);
|
872
|
+
$("#"+nm,"#"+fmid).attr("defaultChecked",true); //ie
|
873
|
+
} else {
|
874
|
+
$("#"+nm,"#"+fmid).attr("checked",false);
|
875
|
+
$("#"+nm,"#"+fmid).attr("defaultChecked",""); //ie
|
876
|
+
}
|
877
|
+
}
|
878
|
+
break;
|
879
|
+
case 'custom' :
|
880
|
+
try {
|
881
|
+
if(cm[i].editoptions && $.isFunction(cm[i].editoptions.custom_value)) {
|
882
|
+
var dummy = cm[i].editoptions.custom_value($("#"+nm,"#"+fmid),'set',tmp);
|
883
|
+
} else { throw "e1"; }
|
884
|
+
} catch (e) {
|
885
|
+
if (e=="e1") { info_dialog(jQuery.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,jQuery.jgrid.edit.bClose);}
|
886
|
+
else { info_dialog(jQuery.jgrid.errors.errcap,e.message,jQuery.jgrid.edit.bClose); }
|
887
|
+
}
|
888
|
+
break;
|
889
|
+
}
|
890
|
+
cnt++;
|
891
|
+
}
|
892
|
+
});
|
893
|
+
if(cnt>0) { $("#id_g","#"+frmtb).val(rowid); }
|
894
|
+
}
|
895
|
+
function postIt() {
|
896
|
+
var copydata, ret=[true,"",""], onCS = {}, opers = $t.p.prmNames, idname, oper;
|
897
|
+
if($.isFunction(rp_ge.beforeCheckValues)) {
|
898
|
+
var retvals = rp_ge.beforeCheckValues(postdata,$("#"+frmgr),postdata[$t.p.id+"_id"] == "_empty" ? opers.addoper : opers.editoper);
|
899
|
+
if(retvals && typeof(retvals) === 'object') { postdata = retvals; }
|
900
|
+
}
|
901
|
+
for( var key in postdata ){
|
902
|
+
if(postdata.hasOwnProperty(key)) {
|
903
|
+
ret = checkValues(postdata[key],key,$t);
|
904
|
+
if(ret[0] === false) { break; }
|
905
|
+
}
|
906
|
+
}
|
907
|
+
if(ret[0]) {
|
908
|
+
if( $.isFunction( rp_ge.onclickSubmit)) { onCS = rp_ge.onclickSubmit(rp_ge,postdata) || {}; }
|
909
|
+
if( $.isFunction(rp_ge.beforeSubmit)) { ret = rp_ge.beforeSubmit(postdata,$("#"+frmgr)); }
|
910
|
+
}
|
911
|
+
|
912
|
+
if(ret[0] && !rp_ge.processing) {
|
913
|
+
rp_ge.processing = true;
|
914
|
+
$("#sData", "#"+frmtb+"_2").addClass('ui-state-active');
|
915
|
+
oper = opers.oper;
|
916
|
+
idname = opers.id;
|
917
|
+
// we add to pos data array the action - the name is oper
|
918
|
+
postdata[oper] = ($.trim(postdata[$t.p.id+"_id"]) == "_empty") ? opers.addoper : opers.editoper;
|
919
|
+
if(postdata[oper] != opers.addoper) {
|
920
|
+
postdata[idname] = postdata[$t.p.id+"_id"];
|
921
|
+
} else {
|
922
|
+
// check to see if we have allredy this field in the form and if yes lieve it
|
923
|
+
if( postdata[idname] === undefined ) { postdata[idname] = postdata[$t.p.id+"_id"]; }
|
924
|
+
}
|
925
|
+
delete postdata[$t.p.id+"_id"];
|
926
|
+
postdata = $.extend(postdata,rp_ge.editData,onCS);
|
927
|
+
|
928
|
+
var ajaxOptions = $.extend({
|
929
|
+
url: rp_ge.url ? rp_ge.url : $($t).jqGrid('getGridParam','editurl'),
|
930
|
+
type: rp_ge.mtype,
|
931
|
+
data: $.isFunction(rp_ge.serializeEditData) ? rp_ge.serializeEditData(postdata) : postdata,
|
932
|
+
complete:function(data,Status){
|
933
|
+
if(Status != "success") {
|
934
|
+
ret[0] = false;
|
935
|
+
if ($.isFunction(rp_ge.errorTextFormat)) {
|
936
|
+
ret[1] = rp_ge.errorTextFormat(data);
|
937
|
+
} else {
|
938
|
+
ret[1] = Status + " Status: '" + data.statusText + "'. Error code: " + data.status;
|
939
|
+
}
|
940
|
+
} else {
|
941
|
+
// data is posted successful
|
942
|
+
// execute aftersubmit with the returned data from server
|
943
|
+
if( $.isFunction(rp_ge.afterSubmit) ) {
|
944
|
+
ret = rp_ge.afterSubmit(data,postdata);
|
945
|
+
}
|
946
|
+
}
|
947
|
+
if(ret[0] === false) {
|
948
|
+
$("#FormError>td","#"+frmtb).html(ret[1]);
|
949
|
+
$("#FormError","#"+frmtb).show();
|
950
|
+
} else {
|
951
|
+
// remove some values if formattaer select or checkbox
|
952
|
+
$.each($t.p.colModel, function(i,n){
|
953
|
+
if(extpost[this.name] && this.formatter && this.formatter=='select') {
|
954
|
+
try {delete extpost[this.name];} catch (e) {}
|
955
|
+
}
|
956
|
+
});
|
957
|
+
postdata = $.extend(postdata,extpost);
|
958
|
+
if($t.p.autoencode) {
|
959
|
+
$.each(postdata,function(n,v){
|
960
|
+
postdata[n] = $.jgrid.htmlDecode(v);
|
961
|
+
});
|
962
|
+
}
|
963
|
+
rp_ge.reloadAfterSubmit = rp_ge.reloadAfterSubmit && $t.p.datatype != "local";
|
964
|
+
// the action is add
|
965
|
+
if(postdata[oper] == opers.addoper ) {
|
966
|
+
//id processing
|
967
|
+
// user not set the id ret[2]
|
968
|
+
if(!ret[2]) { ret[2] = (parseInt($t.p.records,10)+1)+""; }
|
969
|
+
postdata[idname] = ret[2];
|
970
|
+
if(rp_ge.closeAfterAdd) {
|
971
|
+
if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); }
|
972
|
+
else {
|
973
|
+
$($t).jqGrid("addRowData",ret[2],postdata,p.addedrow);
|
974
|
+
$($t).jqGrid("setSelection",ret[2]);
|
975
|
+
}
|
976
|
+
hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal,onClose: rp_ge.onClose});
|
977
|
+
} else if (rp_ge.clearAfterAdd) {
|
978
|
+
if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); }
|
979
|
+
else { $($t).jqGrid("addRowData",ret[2],postdata,p.addedrow); }
|
980
|
+
fillData("_empty",$t,frmgr);
|
981
|
+
} else {
|
982
|
+
if(rp_ge.reloadAfterSubmit) { $($t).trigger("reloadGrid"); }
|
983
|
+
else { $($t).jqGrid("addRowData",ret[2],postdata,p.addedrow); }
|
984
|
+
}
|
985
|
+
} else {
|
986
|
+
// the action is update
|
987
|
+
if(rp_ge.reloadAfterSubmit) {
|
988
|
+
$($t).trigger("reloadGrid");
|
989
|
+
if( !rp_ge.closeAfterEdit ) { setTimeout(function(){$($t).jqGrid("setSelection",postdata[idname]);},1000); }
|
990
|
+
} else {
|
991
|
+
if($t.p.treeGrid === true) {
|
992
|
+
$($t).jqGrid("setTreeRow",postdata[idname],postdata);
|
993
|
+
} else {
|
994
|
+
$($t).jqGrid("setRowData",postdata[idname],postdata);
|
995
|
+
}
|
996
|
+
}
|
997
|
+
if(rp_ge.closeAfterEdit) { hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal,onClose: rp_ge.onClose}); }
|
998
|
+
}
|
999
|
+
if($.isFunction(rp_ge.afterComplete)) {
|
1000
|
+
copydata = data;
|
1001
|
+
setTimeout(function(){rp_ge.afterComplete(copydata,postdata,$("#"+frmgr));copydata=null;},500);
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
rp_ge.processing=false;
|
1005
|
+
if(rp_ge.checkOnSubmit || rp_ge.checkOnUpdate) {
|
1006
|
+
$("#"+frmgr).data("disabled",false);
|
1007
|
+
if(rp_ge._savedData[$t.p.id+"_id"] !="_empty"){
|
1008
|
+
for(var key in rp_ge._savedData) {
|
1009
|
+
if(postdata[key]) {
|
1010
|
+
rp_ge._savedData[key] = postdata[key];
|
1011
|
+
}
|
1012
|
+
}
|
1013
|
+
}
|
1014
|
+
}
|
1015
|
+
$("#sData", "#"+frmtb+"_2").removeClass('ui-state-active');
|
1016
|
+
try{$(':input:visible',"#"+frmgr)[0].focus();} catch (e){}
|
1017
|
+
},
|
1018
|
+
error:function(xhr,st,err){
|
1019
|
+
$("#FormError>td","#"+frmtb).html(st+ " : "+err);
|
1020
|
+
$("#FormError","#"+frmtb).show();
|
1021
|
+
rp_ge.processing=false;
|
1022
|
+
$("#"+frmgr).data("disabled",false);
|
1023
|
+
$("#sData", "#"+frmtb+"_2").removeClass('ui-state-active');
|
1024
|
+
}
|
1025
|
+
}, $.jgrid.ajaxOptions, rp_ge.ajaxEditOptions )
|
1026
|
+
|
1027
|
+
if (!ajaxOptions['url'] && !rp_ge['useDataProxy']) {
|
1028
|
+
if ($.isFunction($t.p.dataProxy)) {
|
1029
|
+
rp_ge['useDataProxy'] = true;
|
1030
|
+
} else {
|
1031
|
+
ret[0]=false; ret[1] += " "+$.jgrid.errors.nourl;
|
1032
|
+
}
|
1033
|
+
}
|
1034
|
+
if (ret[0]) {
|
1035
|
+
if (rp_ge['useDataProxy']) { $t.p.dataProxy.call($t, ajaxOptions, "set_"+$t.p.id) }
|
1036
|
+
else { $.ajax(ajaxOptions) }
|
1037
|
+
}
|
1038
|
+
}
|
1039
|
+
if(ret[0] === false) {
|
1040
|
+
$("#FormError>td","#"+frmtb).html(ret[1]);
|
1041
|
+
$("#FormError","#"+frmtb).show();
|
1042
|
+
// return;
|
1043
|
+
}
|
1044
|
+
}
|
1045
|
+
function compareData(nObj, oObj ) {
|
1046
|
+
var ret = false,key;
|
1047
|
+
for (key in nObj) {
|
1048
|
+
if(nObj[key] != oObj[key]) {
|
1049
|
+
ret = true;
|
1050
|
+
break;
|
1051
|
+
}
|
1052
|
+
}
|
1053
|
+
return ret;
|
1054
|
+
}
|
1055
|
+
});
|
1056
|
+
},
|
1057
|
+
viewGridRow : function(rowid, p){
|
1058
|
+
p = $.extend({
|
1059
|
+
top : 0,
|
1060
|
+
left: 0,
|
1061
|
+
width: 0,
|
1062
|
+
height: 'auto',
|
1063
|
+
dataheight: 'auto',
|
1064
|
+
modal: false,
|
1065
|
+
drag: true,
|
1066
|
+
resize: true,
|
1067
|
+
jqModal: true,
|
1068
|
+
closeOnEscape : false,
|
1069
|
+
labelswidth: '30%',
|
1070
|
+
closeicon: [],
|
1071
|
+
navkeys: [false,38,40],
|
1072
|
+
onClose: null,
|
1073
|
+
beforeShowForm : null,
|
1074
|
+
viewPagerButtons : true
|
1075
|
+
}, $.jgrid.view, p || {});
|
1076
|
+
return this.each(function(){
|
1077
|
+
var $t = this;
|
1078
|
+
if (!$t.grid || !rowid) { return; }
|
1079
|
+
if(!p.imgpath) { p.imgpath= $t.p.imgpath; }
|
1080
|
+
// I hate to rewrite code, but ...
|
1081
|
+
var gID = $t.p.id,
|
1082
|
+
frmgr = "ViewGrid_"+gID , frmtb = "ViewTbl_"+gID,
|
1083
|
+
IDs = {themodal:'viewmod'+gID,modalhead:'viewhd'+gID,modalcontent:'viewcnt'+gID, scrollelm : frmgr},
|
1084
|
+
maxCols = 1, maxRows=0;
|
1085
|
+
if ( $("#"+IDs.themodal).html() != null ) {
|
1086
|
+
$(".ui-jqdialog-title","#"+IDs.modalhead).html(p.caption);
|
1087
|
+
$("#FormError","#"+frmtb).hide();
|
1088
|
+
fillData(rowid,$t);
|
1089
|
+
if($.isFunction(p.beforeShowForm)) { p.beforeShowForm($("#"+frmgr)); }
|
1090
|
+
viewModal("#"+IDs.themodal,{gbox:"#gbox_"+gID,jqm:p.jqModal, jqM: false, modal:p.modal});
|
1091
|
+
focusaref();
|
1092
|
+
} else {
|
1093
|
+
$($t.p.colModel).each( function(i) {
|
1094
|
+
var fmto = this.formoptions;
|
1095
|
+
maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 );
|
1096
|
+
maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 );
|
1097
|
+
});
|
1098
|
+
var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px";
|
1099
|
+
var flr, frm = $("<form name='FormPost' id='"+frmgr+"' class='FormGrid' style='width:100%;overflow:auto;position:relative;height:"+dh+";'></form>"),
|
1100
|
+
tbl =$("<table id='"+frmtb+"' class='EditTable' cellspacing='1' cellpading='2' border='0' style='table-layout:fixed'><tbody></tbody></table>");
|
1101
|
+
// set the id.
|
1102
|
+
$(frm).append(tbl);
|
1103
|
+
var valref = createData(rowid, $t, tbl, maxCols),
|
1104
|
+
rtlb = $t.p.direction == "rtl" ? true :false,
|
1105
|
+
bp = rtlb ? "nData" : "pData",
|
1106
|
+
bn = rtlb ? "pData" : "nData",
|
1107
|
+
|
1108
|
+
// buttons at footer
|
1109
|
+
bP = "<a href='javascript:void(0)' id='"+bp+"' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></div>",
|
1110
|
+
bN = "<a href='javascript:void(0)' id='"+bn+"' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></div>",
|
1111
|
+
bC ="<a href='javascript:void(0)' id='cData' class='fm-button ui-state-default ui-corner-all'>"+p.bClose+"</a>";
|
1112
|
+
if(maxRows > 0) {
|
1113
|
+
var sd=[];
|
1114
|
+
$.each($(tbl)[0].rows,function(i,r){
|
1115
|
+
sd[i] = r;
|
1116
|
+
});
|
1117
|
+
sd.sort(function(a,b){
|
1118
|
+
if(a.rp > b.rp) {return 1;}
|
1119
|
+
if(a.rp < b.rp) {return -1;}
|
1120
|
+
return 0;
|
1121
|
+
});
|
1122
|
+
$.each(sd, function(index, row) {
|
1123
|
+
$('tbody',tbl).append(row);
|
1124
|
+
});
|
1125
|
+
}
|
1126
|
+
p.gbox = "#gbox_"+gID;
|
1127
|
+
var cle = false;
|
1128
|
+
if(p.closeOnEscape===true){
|
1129
|
+
p.closeOnEscape = false;
|
1130
|
+
cle = true;
|
1131
|
+
}
|
1132
|
+
var bt = $("<span></span>").append(frm).append("<table border='0' class='EditTable' id='"+frmtb+"_2'><tbody><tr id='Act_Buttons'><td class='navButton ui-widget-content' width='"+p.labelswidth+"'>"+(rtlb ? bN+bP : bP+bN)+"</td><td class='EditButton ui-widget-content'>"+bC+"</td></tr></tbody></table>");
|
1133
|
+
createModal(IDs,bt,p,"#gview_"+$t.p.id,$("#gview_"+$t.p.id)[0]);
|
1134
|
+
if(rtlb) {
|
1135
|
+
$("#pData, #nData","#"+frmtb+"_2").css("float","right");
|
1136
|
+
$(".EditButton","#"+frmtb+"_2").css("text-align","left");
|
1137
|
+
}
|
1138
|
+
if(!p.viewPagerButtons) { $("#pData, #nData","#"+frmtb+"_2").hide(); }
|
1139
|
+
bt = null;
|
1140
|
+
$("#"+IDs.themodal).keydown( function( e ) {
|
1141
|
+
if(e.which === 27) {
|
1142
|
+
if(cle) { hideModal(this,{gb:p.gbox,jqm:p.jqModal, onClose: p.onClose}); }
|
1143
|
+
return false;
|
1144
|
+
}
|
1145
|
+
if(p.navkeys[0]===true) {
|
1146
|
+
if(e.which === p.navkeys[1]){ //up
|
1147
|
+
$("#pData", "#"+frmtb+"_2").trigger("click");
|
1148
|
+
return false;
|
1149
|
+
}
|
1150
|
+
if(e.which === p.navkeys[2]){ //down
|
1151
|
+
$("#nData", "#"+frmtb+"_2").trigger("click");
|
1152
|
+
return false;
|
1153
|
+
}
|
1154
|
+
}
|
1155
|
+
});
|
1156
|
+
p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon);
|
1157
|
+
if(p.closeicon[0]===true) {
|
1158
|
+
$("#cData","#"+frmtb+"_2").addClass(p.closeicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
|
1159
|
+
.append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
|
1160
|
+
}
|
1161
|
+
if($.isFunction(p.beforeShowForm)) { p.beforeShowForm($("#"+frmgr)); }
|
1162
|
+
viewModal("#"+IDs.themodal,{gbox:"#gbox_"+gID,jqm:p.jqModal, modal:p.modal});
|
1163
|
+
$(".fm-button:not(.ui-state-disabled)","#"+frmtb+"_2").hover(
|
1164
|
+
function(){$(this).addClass('ui-state-hover');},
|
1165
|
+
function(){$(this).removeClass('ui-state-hover');}
|
1166
|
+
);
|
1167
|
+
focusaref();
|
1168
|
+
$("#cData", "#"+frmtb+"_2").click(function(e){
|
1169
|
+
hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal, onClose: p.onClose});
|
1170
|
+
return false;
|
1171
|
+
});
|
1172
|
+
$("#nData", "#"+frmtb+"_2").click(function(e){
|
1173
|
+
$("#FormError","#"+frmtb).hide();
|
1174
|
+
var npos = getCurrPos();
|
1175
|
+
npos[0] = parseInt(npos[0],10);
|
1176
|
+
if(npos[0] != -1 && npos[1][npos[0]+1]) {
|
1177
|
+
if($.isFunction(p.onclickPgButtons)) {
|
1178
|
+
p.onclickPgButtons('next',$("#"+frmgr),npos[1][npos[0]]);
|
1179
|
+
}
|
1180
|
+
fillData(npos[1][npos[0]+1],$t);
|
1181
|
+
$($t).jqGrid("setSelection",npos[1][npos[0]+1]);
|
1182
|
+
if($.isFunction(p.afterclickPgButtons)) {
|
1183
|
+
p.afterclickPgButtons('next',$("#"+frmgr),npos[1][npos[0]+1]);
|
1184
|
+
}
|
1185
|
+
updateNav(npos[0]+1,npos[1].length-1);
|
1186
|
+
}
|
1187
|
+
focusaref();
|
1188
|
+
return false;
|
1189
|
+
});
|
1190
|
+
$("#pData", "#"+frmtb+"_2").click(function(e){
|
1191
|
+
$("#FormError","#"+frmtb).hide();
|
1192
|
+
var ppos = getCurrPos();
|
1193
|
+
if(ppos[0] != -1 && ppos[1][ppos[0]-1]) {
|
1194
|
+
if($.isFunction(p.onclickPgButtons)) {
|
1195
|
+
p.onclickPgButtons('prev',$("#"+frmgr),ppos[1][ppos[0]]);
|
1196
|
+
}
|
1197
|
+
fillData(ppos[1][ppos[0]-1],$t);
|
1198
|
+
$($t).jqGrid("setSelection",ppos[1][ppos[0]-1]);
|
1199
|
+
if($.isFunction(p.afterclickPgButtons)) {
|
1200
|
+
p.afterclickPgButtons('prev',$("#"+frmgr),ppos[1][ppos[0]-1]);
|
1201
|
+
}
|
1202
|
+
updateNav(ppos[0]-1,ppos[1].length-1);
|
1203
|
+
}
|
1204
|
+
focusaref();
|
1205
|
+
return false;
|
1206
|
+
});
|
1207
|
+
}
|
1208
|
+
function focusaref(){ //Sfari 3 issues
|
1209
|
+
if(p.closeOnEscape===true || p.navkeys[0]===true) {
|
1210
|
+
setTimeout(function(){$(".ui-jqdialog-titlebar-close","#"+IDs.modalhead).focus();},0);
|
1211
|
+
}
|
1212
|
+
}
|
1213
|
+
var posInit =getCurrPos();
|
1214
|
+
updateNav(posInit[0],posInit[1].length-1);
|
1215
|
+
function updateNav(cr,totr,rid){
|
1216
|
+
if (cr===0) { $("#pData","#"+frmtb+"_2").addClass('ui-state-disabled'); } else { $("#pData","#"+frmtb+"_2").removeClass('ui-state-disabled'); }
|
1217
|
+
if (cr==totr) { $("#nData","#"+frmtb+"_2").addClass('ui-state-disabled'); } else { $("#nData","#"+frmtb+"_2").removeClass('ui-state-disabled'); }
|
1218
|
+
}
|
1219
|
+
function getCurrPos() {
|
1220
|
+
var rowsInGrid = $($t).jqGrid("getDataIDs"),
|
1221
|
+
selrow = $("#id_g","#"+frmtb).val(),
|
1222
|
+
pos = $.inArray(selrow,rowsInGrid);
|
1223
|
+
return [pos,rowsInGrid];
|
1224
|
+
}
|
1225
|
+
function createData(rowid,obj,tb,maxcols){
|
1226
|
+
var nm, hc,trdata, tdl, tde, cnt=0,tmp, dc, retpos=[], ind=false,
|
1227
|
+
tdtmpl = "<td class='CaptionTD form-view-label ui-widget-content' width='"+p.labelswidth+"'> </td><td class='DataTD form-view-data ui-helper-reset ui-widget-content'> </td>", tmpl="",
|
1228
|
+
tdtmpl2 = "<td class='CaptionTD form-view-label ui-widget-content'> </td><td class='DataTD form-view-data ui-widget-content'> </td>",
|
1229
|
+
fmtnum = ['integer','number','currency'],max1 =0, max2=0 ,maxw,setme, viewfld;
|
1230
|
+
for (var i =1;i<=maxcols;i++) {
|
1231
|
+
tmpl += i == 1 ? tdtmpl : tdtmpl2;
|
1232
|
+
}
|
1233
|
+
// find max number align rigth with property formatter
|
1234
|
+
$(obj.p.colModel).each( function(i) {
|
1235
|
+
if(this.editrules && this.editrules.edithidden === true) {
|
1236
|
+
hc = false;
|
1237
|
+
} else {
|
1238
|
+
hc = this.hidden === true ? true : false;
|
1239
|
+
}
|
1240
|
+
if(!hc && this.align==='right') {
|
1241
|
+
if(this.formatter && $.inArray(this.formatter,fmtnum) !== -1 ) {
|
1242
|
+
max1 = Math.max(max1,parseInt(this.width,10));
|
1243
|
+
} else {
|
1244
|
+
max2 = Math.max(max2,parseInt(this.width,10));
|
1245
|
+
}
|
1246
|
+
}
|
1247
|
+
});
|
1248
|
+
maxw = max1 !==0 ? max1 : max2 !==0 ? max2 : 0;
|
1249
|
+
ind = $(obj).jqGrid("getInd",rowid);
|
1250
|
+
$(obj.p.colModel).each( function(i) {
|
1251
|
+
nm = this.name;
|
1252
|
+
setme = false;
|
1253
|
+
// hidden fields are included in the form
|
1254
|
+
if(this.editrules && this.editrules.edithidden === true) {
|
1255
|
+
hc = false;
|
1256
|
+
} else {
|
1257
|
+
hc = this.hidden === true ? true : false;
|
1258
|
+
}
|
1259
|
+
dc = hc ? "style='display:none'" : "";
|
1260
|
+
viewfld = (typeof this.viewable != 'boolean') ? true : this.viewable;
|
1261
|
+
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn' && viewfld) {
|
1262
|
+
if(ind === false) {
|
1263
|
+
tmp = "";
|
1264
|
+
} else {
|
1265
|
+
if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) {
|
1266
|
+
tmp = $("td:eq("+i+")",obj.rows[ind]).text();
|
1267
|
+
} else {
|
1268
|
+
tmp = $("td:eq("+i+")",obj.rows[ind]).html();
|
1269
|
+
}
|
1270
|
+
}
|
1271
|
+
setme = this.align === 'right' && maxw !==0 ? true : false;
|
1272
|
+
var opt = $.extend({}, this.editoptions || {} ,{id:nm,name:nm}),
|
1273
|
+
frmopt = $.extend({},{rowabove:false,rowcontent:''}, this.formoptions || {}),
|
1274
|
+
rp = parseInt(frmopt.rowpos,10) || cnt+1,
|
1275
|
+
cp = parseInt((parseInt(frmopt.colpos,10) || 1)*2,10);
|
1276
|
+
if(frmopt.rowabove) {
|
1277
|
+
var newdata = $("<tr><td class='contentinfo' colspan='"+(maxcols*2)+"'>"+frmopt.rowcontent+"</td></tr>");
|
1278
|
+
$(tb).append(newdata);
|
1279
|
+
newdata[0].rp = rp;
|
1280
|
+
}
|
1281
|
+
trdata = $(tb).find("tr[rowpos="+rp+"]");
|
1282
|
+
if ( trdata.length===0 ) {
|
1283
|
+
trdata = $("<tr "+dc+" rowpos='"+rp+"'></tr>").addClass("FormData").attr("id","trv_"+nm);
|
1284
|
+
$(trdata).append(tmpl);
|
1285
|
+
$(tb).append(trdata);
|
1286
|
+
trdata[0].rp = rp;
|
1287
|
+
}
|
1288
|
+
$("td:eq("+(cp-2)+")",trdata[0]).html('<b>'+ (typeof frmopt.label === 'undefined' ? obj.p.colNames[i]: frmopt.label)+'</b>');
|
1289
|
+
$("td:eq("+(cp-1)+")",trdata[0]).append("<span>"+tmp+"</span>").attr("id","v_"+nm);
|
1290
|
+
if(setme){
|
1291
|
+
$("td:eq("+(cp-1)+") span",trdata[0]).css({'text-align':'right',width:maxw+"px"});
|
1292
|
+
}
|
1293
|
+
retpos[cnt] = i;
|
1294
|
+
cnt++;
|
1295
|
+
}
|
1296
|
+
});
|
1297
|
+
if( cnt > 0) {
|
1298
|
+
var idrow = $("<tr class='FormData' style='display:none'><td class='CaptionTD'></td><td colspan='"+ (maxcols*2-1)+"' class='DataTD'><input class='FormElement' id='id_g' type='text' name='id' value='"+rowid+"'/></td></tr>");
|
1299
|
+
idrow[0].rp = cnt+99;
|
1300
|
+
$(tb).append(idrow);
|
1301
|
+
}
|
1302
|
+
return retpos;
|
1303
|
+
}
|
1304
|
+
function fillData(rowid,obj){
|
1305
|
+
var nm, hc,cnt=0,tmp, opt,trv;
|
1306
|
+
trv = $(obj).jqGrid("getInd",rowid,true);
|
1307
|
+
if(!trv) { return; }
|
1308
|
+
$('td',trv).each( function(i) {
|
1309
|
+
nm = obj.p.colModel[i].name;
|
1310
|
+
// hidden fields are included in the form
|
1311
|
+
if(obj.p.colModel[i].editrules && obj.p.colModel[i].editrules.edithidden === true) {
|
1312
|
+
hc = false;
|
1313
|
+
} else {
|
1314
|
+
hc = obj.p.colModel[i].hidden === true ? true : false;
|
1315
|
+
}
|
1316
|
+
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') {
|
1317
|
+
if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) {
|
1318
|
+
tmp = $(this).text();
|
1319
|
+
} else {
|
1320
|
+
tmp = $(this).html();
|
1321
|
+
}
|
1322
|
+
opt = $.extend({},obj.p.colModel[i].editoptions || {});
|
1323
|
+
nm = $.jgrid.jqID("v_"+nm);
|
1324
|
+
$("#"+nm+" span","#"+frmtb).html(tmp);
|
1325
|
+
if (hc) { $("#"+nm,"#"+frmtb).parents("tr:first").hide(); }
|
1326
|
+
cnt++;
|
1327
|
+
}
|
1328
|
+
});
|
1329
|
+
if(cnt>0) { $("#id_g","#"+frmtb).val(rowid); }
|
1330
|
+
}
|
1331
|
+
});
|
1332
|
+
},
|
1333
|
+
delGridRow : function(rowids,p) {
|
1334
|
+
p = $.extend({
|
1335
|
+
top : 0,
|
1336
|
+
left: 0,
|
1337
|
+
width: 240,
|
1338
|
+
height: 'auto',
|
1339
|
+
dataheight : 'auto',
|
1340
|
+
modal: false,
|
1341
|
+
drag: true,
|
1342
|
+
resize: true,
|
1343
|
+
url : '',
|
1344
|
+
mtype : "POST",
|
1345
|
+
reloadAfterSubmit: true,
|
1346
|
+
beforeShowForm: null,
|
1347
|
+
afterShowForm: null,
|
1348
|
+
beforeSubmit: null,
|
1349
|
+
onclickSubmit: null,
|
1350
|
+
afterSubmit: null,
|
1351
|
+
jqModal : true,
|
1352
|
+
closeOnEscape : false,
|
1353
|
+
delData: {},
|
1354
|
+
delicon : [],
|
1355
|
+
cancelicon : [],
|
1356
|
+
onClose : null,
|
1357
|
+
ajaxDelOptions : {},
|
1358
|
+
processing : false,
|
1359
|
+
serializeDelData : null,
|
1360
|
+
useDataProxy : false
|
1361
|
+
}, $.jgrid.del, p ||{});
|
1362
|
+
rp_ge = p;
|
1363
|
+
return this.each(function(){
|
1364
|
+
var $t = this;
|
1365
|
+
if (!$t.grid ) { return; }
|
1366
|
+
if(!rowids) { return; }
|
1367
|
+
var onBeforeShow = typeof p.beforeShowForm === 'function' ? true: false,
|
1368
|
+
onAfterShow = typeof p.afterShowForm === 'function' ? true: false,
|
1369
|
+
gID = $t.p.id, onCS = {},
|
1370
|
+
dtbl = "DelTbl_"+gID,postd, idname, opers, oper,
|
1371
|
+
IDs = {themodal:'delmod'+gID,modalhead:'delhd'+gID,modalcontent:'delcnt'+gID, scrollelm: dtbl};
|
1372
|
+
if (jQuery.isArray(rowids)) { rowids = rowids.join(); }
|
1373
|
+
if ( $("#"+IDs.themodal).html() != null ) {
|
1374
|
+
$("#DelData>td","#"+dtbl).text(rowids);
|
1375
|
+
$("#DelError","#"+dtbl).hide();
|
1376
|
+
if( rp_ge.processing === true) {
|
1377
|
+
rp_ge.processing=false;
|
1378
|
+
$("#dData", "#"+dtbl).removeClass('ui-state-active');
|
1379
|
+
}
|
1380
|
+
if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); }
|
1381
|
+
viewModal("#"+IDs.themodal,{gbox:"#gbox_"+gID,jqm:p.jqModal,jqM: false, modal:p.modal});
|
1382
|
+
if(onAfterShow) { p.afterShowForm($("#"+dtbl)); }
|
1383
|
+
} else {
|
1384
|
+
var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px";
|
1385
|
+
var tbl = "<div id='"+dtbl+"' class='formdata' style='width:100%;overflow:auto;position:relative;height:"+dh+";'>";
|
1386
|
+
tbl += "<table class='DelTable'><tbody>";
|
1387
|
+
// error data
|
1388
|
+
tbl += "<tr id='DelError' style='display:none'><td class='ui-state-error'></td></tr>";
|
1389
|
+
tbl += "<tr id='DelData' style='display:none'><td >"+rowids+"</td></tr>";
|
1390
|
+
tbl += "<tr><td class=\"delmsg\" style=\"white-space:pre;\">"+p.msg+"</td></tr><tr><td > </td></tr>";
|
1391
|
+
// buttons at footer
|
1392
|
+
tbl += "</tbody></table></div>";
|
1393
|
+
var bS = "<a href='javascript:void(0)' id='dData' class='fm-button ui-state-default ui-corner-all'>"+p.bSubmit+"</a>",
|
1394
|
+
bC = "<a href='javascript:void(0)' id='eData' class='fm-button ui-state-default ui-corner-all'>"+p.bCancel+"</a>";
|
1395
|
+
tbl += "<table cellspacing='0' cellpadding='0' border='0' class='EditTable' id='"+dtbl+"_2'><tbody><tr><td class='DataTD ui-widget-content'></td></tr><tr style='display:block;height:3px;'><td></td></tr><tr><td class='DelButton EditButton'>"+bS+" "+bC+"</td></tr></tbody></table>";
|
1396
|
+
p.gbox = "#gbox_"+gID;
|
1397
|
+
createModal(IDs,tbl,p,"#gview_"+$t.p.id,$("#gview_"+$t.p.id)[0]);
|
1398
|
+
$(".fm-button","#"+dtbl+"_2").hover(
|
1399
|
+
function(){$(this).addClass('ui-state-hover');},
|
1400
|
+
function(){$(this).removeClass('ui-state-hover');}
|
1401
|
+
);
|
1402
|
+
p.delicon = $.extend([true,"left","ui-icon-scissors"],p.delicon);
|
1403
|
+
p.cancelicon = $.extend([true,"left","ui-icon-cancel"],p.cancelicon);
|
1404
|
+
if(p.delicon[0]===true) {
|
1405
|
+
$("#dData","#"+dtbl+"_2").addClass(p.delicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
|
1406
|
+
.append("<span class='ui-icon "+p.delicon[2]+"'></span>");
|
1407
|
+
}
|
1408
|
+
if(p.cancelicon[0]===true) {
|
1409
|
+
$("#eData","#"+dtbl+"_2").addClass(p.cancelicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
|
1410
|
+
.append("<span class='ui-icon "+p.cancelicon[2]+"'></span>");
|
1411
|
+
}
|
1412
|
+
$("#dData","#"+dtbl+"_2").click(function(e){
|
1413
|
+
var ret=[true,""]; onCS = {};
|
1414
|
+
var postdata = $("#DelData>td","#"+dtbl).text(); //the pair is name=val1,val2,...
|
1415
|
+
if( typeof p.onclickSubmit === 'function' ) { onCS = p.onclickSubmit(rp_ge, postdata) || {}; }
|
1416
|
+
if( typeof p.beforeSubmit === 'function' ) { ret = p.beforeSubmit(postdata); }
|
1417
|
+
if(ret[0] && !rp_ge.processing) {
|
1418
|
+
rp_ge.processing = true;
|
1419
|
+
$(this).addClass('ui-state-active');
|
1420
|
+
opers = $t.p.prmNames;
|
1421
|
+
postd = $.extend({},rp_ge.delData, onCS);
|
1422
|
+
oper = opers.oper;
|
1423
|
+
postd[oper] = opers.deloper;
|
1424
|
+
idname = opers.id;
|
1425
|
+
postd[idname] = postdata;
|
1426
|
+
|
1427
|
+
var ajaxOptions = $.extend({
|
1428
|
+
url: rp_ge.url ? rp_ge.url : $($t).jqGrid('getGridParam','editurl'),
|
1429
|
+
type: p.mtype,
|
1430
|
+
data: $.isFunction(p.serializeDelData) ? p.serializeDelData(postd) : postd,
|
1431
|
+
complete:function(data,Status){
|
1432
|
+
if(Status != "success") {
|
1433
|
+
ret[0] = false;
|
1434
|
+
if ($.isFunction(rp_ge.errorTextFormat)) {
|
1435
|
+
ret[1] = rp_ge.errorTextFormat(data);
|
1436
|
+
} else {
|
1437
|
+
ret[1] = Status + " Status: '" + data.statusText + "'. Error code: " + data.status;
|
1438
|
+
}
|
1439
|
+
} else {
|
1440
|
+
// data is posted successful
|
1441
|
+
// execute aftersubmit with the returned data from server
|
1442
|
+
if( typeof rp_ge.afterSubmit === 'function' ) {
|
1443
|
+
ret = rp_ge.afterSubmit(data,postd);
|
1444
|
+
}
|
1445
|
+
}
|
1446
|
+
if(ret[0] === false) {
|
1447
|
+
$("#DelError>td","#"+dtbl).html(ret[1]);
|
1448
|
+
$("#DelError","#"+dtbl).show();
|
1449
|
+
} else {
|
1450
|
+
if(rp_ge.reloadAfterSubmit && $t.p.datatype != "local") {
|
1451
|
+
$($t).trigger("reloadGrid");
|
1452
|
+
} else {
|
1453
|
+
var toarr = [];
|
1454
|
+
toarr = postdata.split(",");
|
1455
|
+
if($t.p.treeGrid===true){
|
1456
|
+
try {$($t).jqGrid("delTreeNode",toarr[0]);} catch(e){}
|
1457
|
+
} else {
|
1458
|
+
for(var i=0;i<toarr.length;i++) {
|
1459
|
+
$($t).jqGrid("delRowData",toarr[i]);
|
1460
|
+
}
|
1461
|
+
}
|
1462
|
+
$t.p.selrow = null;
|
1463
|
+
$t.p.selarrrow = [];
|
1464
|
+
}
|
1465
|
+
if($.isFunction(rp_ge.afterComplete)) {
|
1466
|
+
setTimeout(function(){rp_ge.afterComplete(data,postdata);},500);
|
1467
|
+
}
|
1468
|
+
}
|
1469
|
+
rp_ge.processing=false;
|
1470
|
+
$("#dData", "#"+dtbl+"_2").removeClass('ui-state-active');
|
1471
|
+
if(ret[0]) { hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal, onClose: rp_ge.onClose}); }
|
1472
|
+
},
|
1473
|
+
error:function(xhr,st,err){
|
1474
|
+
$("#DelError>td","#"+dtbl).html(st+ " : "+err);
|
1475
|
+
$("#DelError","#"+dtbl).show();
|
1476
|
+
rp_ge.processing=false;
|
1477
|
+
$("#dData", "#"+dtbl+"_2").removeClass('ui-state-active');
|
1478
|
+
}
|
1479
|
+
}, $.jgrid.ajaxOptions, p.ajaxDelOptions);
|
1480
|
+
|
1481
|
+
|
1482
|
+
if (!ajaxOptions['url'] && !rp_ge['useDataProxy']) {
|
1483
|
+
if ($.isFunction($t.p.dataProxy)) {
|
1484
|
+
rp_ge['useDataProxy'] = true;
|
1485
|
+
} else {
|
1486
|
+
ret[0]=false; ret[1] += " "+$.jgrid.errors.nourl;
|
1487
|
+
}
|
1488
|
+
}
|
1489
|
+
if (ret[0]) {
|
1490
|
+
if (rp_ge['useDataProxy']) { $t.p.dataProxy.call($t, ajaxOptions, "del_"+$t.p.id) }
|
1491
|
+
else { $.ajax(ajaxOptions) }
|
1492
|
+
}
|
1493
|
+
}
|
1494
|
+
|
1495
|
+
if(ret[0] === false) {
|
1496
|
+
$("#DelError>td","#"+dtbl).html(ret[1]);
|
1497
|
+
$("#DelError","#"+dtbl).show();
|
1498
|
+
}
|
1499
|
+
return false;
|
1500
|
+
});
|
1501
|
+
$("#eData", "#"+dtbl+"_2").click(function(e){
|
1502
|
+
hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal, onClose: rp_ge.onClose});
|
1503
|
+
return false;
|
1504
|
+
});
|
1505
|
+
if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); }
|
1506
|
+
viewModal("#"+IDs.themodal,{gbox:"#gbox_"+gID,jqm:p.jqModal,modal:p.modal});
|
1507
|
+
if(onAfterShow) { p.afterShowForm($("#"+dtbl)); }
|
1508
|
+
}
|
1509
|
+
if(p.closeOnEscape===true) {
|
1510
|
+
setTimeout(function(){$(".ui-jqdialog-titlebar-close","#"+IDs.modalhead).focus();},0);
|
1511
|
+
}
|
1512
|
+
});
|
1513
|
+
},
|
1514
|
+
navGrid : function (elem, o, pEdit,pAdd,pDel,pSearch, pView) {
|
1515
|
+
o = $.extend({
|
1516
|
+
edit: true,
|
1517
|
+
editicon: "ui-icon-pencil",
|
1518
|
+
add: true,
|
1519
|
+
addicon:"ui-icon-plus",
|
1520
|
+
del: true,
|
1521
|
+
delicon:"ui-icon-trash",
|
1522
|
+
search: true,
|
1523
|
+
searchicon:"ui-icon-search",
|
1524
|
+
refresh: true,
|
1525
|
+
refreshicon:"ui-icon-refresh",
|
1526
|
+
refreshstate: 'firstpage',
|
1527
|
+
view: false,
|
1528
|
+
viewicon : "ui-icon-document",
|
1529
|
+
position : "left",
|
1530
|
+
closeOnEscape : true,
|
1531
|
+
beforeRefresh : null,
|
1532
|
+
afterRefresh : null,
|
1533
|
+
cloneToTop : false
|
1534
|
+
}, $.jgrid.nav, o ||{});
|
1535
|
+
return this.each(function() {
|
1536
|
+
var alertIDs = {themodal:'alertmod',modalhead:'alerthd',modalcontent:'alertcnt'},
|
1537
|
+
$t = this, vwidth, vheight, twd, tdw;
|
1538
|
+
if(!$t.grid || typeof elem != 'string') { return; }
|
1539
|
+
if ($("#"+alertIDs.themodal).html() === null) {
|
1540
|
+
if (typeof window.innerWidth != 'undefined') {
|
1541
|
+
vwidth = window.innerWidth;
|
1542
|
+
vheight = window.innerHeight;
|
1543
|
+
} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth !== 0) {
|
1544
|
+
vwidth = document.documentElement.clientWidth;
|
1545
|
+
vheight = document.documentElement.clientHeight;
|
1546
|
+
} else {
|
1547
|
+
vwidth=1024;
|
1548
|
+
vheight=768;
|
1549
|
+
}
|
1550
|
+
createModal(alertIDs,"<div>"+o.alerttext+"</div><span tabindex='0'><span tabindex='-1' id='jqg_alrt'></span></span>",{gbox:"#gbox_"+$t.p.id,jqModal:true,drag:true,resize:true,caption:o.alertcap,top:vheight/2-25,left:vwidth/2-100,width:200,height:'auto',closeOnEscape:o.closeOnEscape},"","",true);
|
1551
|
+
}
|
1552
|
+
var clone = 1;
|
1553
|
+
if(o.cloneToTop && $t.p.toppager) { clone = 2; }
|
1554
|
+
for(var i = 0; i<clone; i++) {
|
1555
|
+
var tbd,
|
1556
|
+
navtbl = $("<table cellspacing='0' cellpadding='0' border='0' class='ui-pg-table navtable' style='float:left;table-layout:auto;'><tbody><tr></tr></tbody></table>"),
|
1557
|
+
sep = "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='ui-separator'></span></td>",
|
1558
|
+
pgid, elemids;
|
1559
|
+
if(i===0) {
|
1560
|
+
pgid = elem;
|
1561
|
+
elemids = $t.p.id;
|
1562
|
+
if(pgid == $t.p.toppager) {
|
1563
|
+
elemids += "_top";
|
1564
|
+
clone = 1;
|
1565
|
+
}
|
1566
|
+
} else {
|
1567
|
+
pgid = $t.p.toppager;
|
1568
|
+
elemids = $t.p.id+"_top";
|
1569
|
+
}
|
1570
|
+
if($t.p.direction == "rtl") { $(navtbl).attr("dir","rtl").css("float","right"); }
|
1571
|
+
if (o.add) {
|
1572
|
+
pAdd = pAdd || {};
|
1573
|
+
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
|
1574
|
+
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.addicon+"'></span>"+o.addtext+"</div>");
|
1575
|
+
$("tr",navtbl).append(tbd);
|
1576
|
+
$(tbd,navtbl)
|
1577
|
+
.attr({"title":o.addtitle || "",id : pAdd.id || "add_"+elemids})
|
1578
|
+
.click(function(){
|
1579
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1580
|
+
if (typeof o.addfunc == 'function') {
|
1581
|
+
o.addfunc();
|
1582
|
+
} else {
|
1583
|
+
$($t).jqGrid("editGridRow","new",pAdd);
|
1584
|
+
}
|
1585
|
+
}
|
1586
|
+
return false;
|
1587
|
+
}).hover(
|
1588
|
+
function () {
|
1589
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1590
|
+
$(this).addClass("ui-state-hover");
|
1591
|
+
}
|
1592
|
+
},
|
1593
|
+
function () {$(this).removeClass("ui-state-hover");}
|
1594
|
+
);
|
1595
|
+
tbd = null;
|
1596
|
+
}
|
1597
|
+
if (o.edit) {
|
1598
|
+
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
|
1599
|
+
pEdit = pEdit || {};
|
1600
|
+
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.editicon+"'></span>"+o.edittext+"</div>");
|
1601
|
+
$("tr",navtbl).append(tbd);
|
1602
|
+
$(tbd,navtbl)
|
1603
|
+
.attr({"title":o.edittitle || "",id: pEdit.id || "edit_"+elemids})
|
1604
|
+
.click(function(){
|
1605
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1606
|
+
var sr = $t.p.selrow;
|
1607
|
+
if (sr) {
|
1608
|
+
if(typeof o.editfunc == 'function') {
|
1609
|
+
o.editfunc(sr);
|
1610
|
+
} else {
|
1611
|
+
$($t).jqGrid("editGridRow",sr,pEdit);
|
1612
|
+
}
|
1613
|
+
} else {
|
1614
|
+
viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$t.p.id,jqm:true});
|
1615
|
+
$("#jqg_alrt").focus();
|
1616
|
+
}
|
1617
|
+
}
|
1618
|
+
return false;
|
1619
|
+
}).hover(
|
1620
|
+
function () {
|
1621
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1622
|
+
$(this).addClass("ui-state-hover");
|
1623
|
+
}
|
1624
|
+
},
|
1625
|
+
function () {$(this).removeClass("ui-state-hover");}
|
1626
|
+
);
|
1627
|
+
tbd = null;
|
1628
|
+
}
|
1629
|
+
if (o.view) {
|
1630
|
+
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
|
1631
|
+
pView = pView || {};
|
1632
|
+
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.viewicon+"'></span>"+o.viewtext+"</div>");
|
1633
|
+
$("tr",navtbl).append(tbd);
|
1634
|
+
$(tbd,navtbl)
|
1635
|
+
.attr({"title":o.viewtitle || "",id: pView.id || "view_"+elemids})
|
1636
|
+
.click(function(){
|
1637
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1638
|
+
var sr = $t.p.selrow;
|
1639
|
+
if (sr) {
|
1640
|
+
$($t).jqGrid("viewGridRow",sr,pView);
|
1641
|
+
} else {
|
1642
|
+
viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$t.p.id,jqm:true});
|
1643
|
+
$("#jqg_alrt").focus();
|
1644
|
+
}
|
1645
|
+
}
|
1646
|
+
return false;
|
1647
|
+
}).hover(
|
1648
|
+
function () {
|
1649
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1650
|
+
$(this).addClass("ui-state-hover");
|
1651
|
+
}
|
1652
|
+
},
|
1653
|
+
function () {$(this).removeClass("ui-state-hover");}
|
1654
|
+
);
|
1655
|
+
tbd = null;
|
1656
|
+
}
|
1657
|
+
if (o.del) {
|
1658
|
+
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
|
1659
|
+
pDel = pDel || {};
|
1660
|
+
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.delicon+"'></span>"+o.deltext+"</div>");
|
1661
|
+
$("tr",navtbl).append(tbd);
|
1662
|
+
$(tbd,navtbl)
|
1663
|
+
.attr({"title":o.deltitle || "",id: pDel.id || "del_"+elemids})
|
1664
|
+
.click(function(){
|
1665
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1666
|
+
var dr;
|
1667
|
+
if($t.p.multiselect) {
|
1668
|
+
dr = $t.p.selarrrow;
|
1669
|
+
if(dr.length===0) { dr = null; }
|
1670
|
+
} else {
|
1671
|
+
dr = $t.p.selrow;
|
1672
|
+
}
|
1673
|
+
if(dr){
|
1674
|
+
if("function" == typeof o.delfunc){
|
1675
|
+
o.delfunc(dr);
|
1676
|
+
}else{
|
1677
|
+
$($t).jqGrid("delGridRow",dr,pDel);
|
1678
|
+
}
|
1679
|
+
} else {
|
1680
|
+
viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$t.p.id,jqm:true}); $("#jqg_alrt").focus();
|
1681
|
+
}
|
1682
|
+
}
|
1683
|
+
return false;
|
1684
|
+
}).hover(
|
1685
|
+
function () {
|
1686
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1687
|
+
$(this).addClass("ui-state-hover");
|
1688
|
+
}
|
1689
|
+
},
|
1690
|
+
function () {$(this).removeClass("ui-state-hover");}
|
1691
|
+
);
|
1692
|
+
tbd = null;
|
1693
|
+
}
|
1694
|
+
if(o.add || o.edit || o.del || o.view) { $("tr",navtbl).append(sep); }
|
1695
|
+
if (o.search) {
|
1696
|
+
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
|
1697
|
+
pSearch = pSearch || {};
|
1698
|
+
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.searchicon+"'></span>"+o.searchtext+"</div>");
|
1699
|
+
$("tr",navtbl).append(tbd);
|
1700
|
+
$(tbd,navtbl)
|
1701
|
+
.attr({"title":o.searchtitle || "",id:pSearch.id || "search_"+elemids})
|
1702
|
+
.click(function(){
|
1703
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1704
|
+
$($t).jqGrid("searchGrid",pSearch);
|
1705
|
+
}
|
1706
|
+
return false;
|
1707
|
+
}).hover(
|
1708
|
+
function () {
|
1709
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1710
|
+
$(this).addClass("ui-state-hover");
|
1711
|
+
}
|
1712
|
+
},
|
1713
|
+
function () {$(this).removeClass("ui-state-hover");}
|
1714
|
+
);
|
1715
|
+
tbd = null;
|
1716
|
+
}
|
1717
|
+
if (o.refresh) {
|
1718
|
+
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
|
1719
|
+
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.refreshicon+"'></span>"+o.refreshtext+"</div>");
|
1720
|
+
$("tr",navtbl).append(tbd);
|
1721
|
+
$(tbd,navtbl)
|
1722
|
+
.attr({"title":o.refreshtitle || "",id: "refresh_"+elemids})
|
1723
|
+
.click(function(){
|
1724
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1725
|
+
if($.isFunction(o.beforeRefresh)) { o.beforeRefresh(); }
|
1726
|
+
$t.p.search = false;
|
1727
|
+
try {
|
1728
|
+
var gID = $t.p.id;
|
1729
|
+
$("#fbox_"+gID).searchFilter().reset({"reload":false});
|
1730
|
+
if($.isFunction($t.clearToolbar)) { $t.clearToolbar(false); }
|
1731
|
+
} catch (e) {}
|
1732
|
+
switch (o.refreshstate) {
|
1733
|
+
case 'firstpage':
|
1734
|
+
$($t).trigger("reloadGrid", [{page:1}]);
|
1735
|
+
break;
|
1736
|
+
case 'current':
|
1737
|
+
$($t).trigger("reloadGrid", [{current:true}]);
|
1738
|
+
break;
|
1739
|
+
}
|
1740
|
+
if($.isFunction(o.afterRefresh)) { o.afterRefresh(); }
|
1741
|
+
}
|
1742
|
+
return false;
|
1743
|
+
}).hover(
|
1744
|
+
function () {
|
1745
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1746
|
+
$(this).addClass("ui-state-hover");
|
1747
|
+
}
|
1748
|
+
},
|
1749
|
+
function () {$(this).removeClass("ui-state-hover");}
|
1750
|
+
);
|
1751
|
+
tbd = null;
|
1752
|
+
}
|
1753
|
+
tdw = $(".ui-jqgrid").css("font-size") || "11px";
|
1754
|
+
$('body').append("<div id='testpg2' class='ui-jqgrid ui-widget ui-widget-content' style='font-size:"+tdw+";visibility:hidden;' ></div>");
|
1755
|
+
twd = $(navtbl).clone().appendTo("#testpg2").width();
|
1756
|
+
$("#testpg2").remove();
|
1757
|
+
$(pgid+"_"+o.position,pgid).append(navtbl);
|
1758
|
+
if($t.p._nvtd) {
|
1759
|
+
if(twd > $t.p._nvtd[0] ) {
|
1760
|
+
$(pgid+"_"+o.position,pgid).width(twd);
|
1761
|
+
$t.p._nvtd[0] = twd;
|
1762
|
+
}
|
1763
|
+
$t.p._nvtd[1] = twd;
|
1764
|
+
}
|
1765
|
+
tdw =null; twd=null; navtbl =null;
|
1766
|
+
}
|
1767
|
+
});
|
1768
|
+
},
|
1769
|
+
navButtonAdd : function (elem, p) {
|
1770
|
+
p = $.extend({
|
1771
|
+
caption : "newButton",
|
1772
|
+
title: '',
|
1773
|
+
buttonicon : 'ui-icon-newwin',
|
1774
|
+
onClickButton: null,
|
1775
|
+
position : "last",
|
1776
|
+
cursor : 'pointer'
|
1777
|
+
}, p ||{});
|
1778
|
+
return this.each(function() {
|
1779
|
+
if( !this.grid) { return; }
|
1780
|
+
if( elem.indexOf("#") !== 0) { elem = "#"+elem; }
|
1781
|
+
var findnav = $(".navtable",elem)[0], $t = this;
|
1782
|
+
if (findnav) {
|
1783
|
+
var tbd = $("<td></td>");
|
1784
|
+
if(p.buttonicon.toString().toUpperCase() == "NONE") {
|
1785
|
+
$(tbd).addClass('ui-pg-button ui-corner-all').append("<div class='ui-pg-div'>"+p.caption+"</div>");
|
1786
|
+
} else {
|
1787
|
+
$(tbd).addClass('ui-pg-button ui-corner-all').append("<div class='ui-pg-div'><span class='ui-icon "+p.buttonicon+"'></span>"+p.caption+"</div>");
|
1788
|
+
}
|
1789
|
+
if(p.id) {$(tbd).attr("id",p.id);}
|
1790
|
+
if(p.position=='first'){
|
1791
|
+
if(findnav.rows[0].cells.length ===0 ) {
|
1792
|
+
$("tr",findnav).append(tbd);
|
1793
|
+
} else {
|
1794
|
+
$("tr td:eq(0)",findnav).before(tbd);
|
1795
|
+
}
|
1796
|
+
} else {
|
1797
|
+
$("tr",findnav).append(tbd);
|
1798
|
+
}
|
1799
|
+
$(tbd,findnav)
|
1800
|
+
.attr("title",p.title || "")
|
1801
|
+
.click(function(e){
|
1802
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1803
|
+
if ($.isFunction(p.onClickButton) ) { p.onClickButton.call($t,e); }
|
1804
|
+
}
|
1805
|
+
return false;
|
1806
|
+
})
|
1807
|
+
.hover(
|
1808
|
+
function () {
|
1809
|
+
if (!$(this).hasClass('ui-state-disabled')) {
|
1810
|
+
$(this).addClass('ui-state-hover');
|
1811
|
+
}
|
1812
|
+
},
|
1813
|
+
function () {$(this).removeClass("ui-state-hover");}
|
1814
|
+
);
|
1815
|
+
}
|
1816
|
+
});
|
1817
|
+
},
|
1818
|
+
navSeparatorAdd:function (elem,p) {
|
1819
|
+
p = $.extend({
|
1820
|
+
sepclass : "ui-separator",
|
1821
|
+
sepcontent: ''
|
1822
|
+
}, p ||{});
|
1823
|
+
return this.each(function() {
|
1824
|
+
if( !this.grid) { return; }
|
1825
|
+
if( elem.indexOf("#") !== 0) { elem = "#"+elem; }
|
1826
|
+
var findnav = $(".navtable",elem)[0];
|
1827
|
+
if(findnav) {
|
1828
|
+
var sep = "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='"+p.sepclass+"'></span>"+p.sepcontent+"</td>";
|
1829
|
+
$("tr",findnav).append(sep);
|
1830
|
+
}
|
1831
|
+
});
|
1832
|
+
},
|
1833
|
+
GridToForm : function( rowid, formid ) {
|
1834
|
+
return this.each(function(){
|
1835
|
+
var $t = this;
|
1836
|
+
if (!$t.grid) { return; }
|
1837
|
+
var rowdata = $($t).jqGrid("getRowData",rowid);
|
1838
|
+
if (rowdata) {
|
1839
|
+
for(var i in rowdata) {
|
1840
|
+
if ( $("[name="+i+"]",formid).is("input:radio") || $("[name="+i+"]",formid).is("input:checkbox")) {
|
1841
|
+
$("[name="+i+"]",formid).each( function() {
|
1842
|
+
if( $(this).val() == rowdata[i] ) {
|
1843
|
+
$(this).attr("checked","checked");
|
1844
|
+
} else {
|
1845
|
+
$(this).attr("checked","");
|
1846
|
+
}
|
1847
|
+
});
|
1848
|
+
} else {
|
1849
|
+
// this is very slow on big table and form.
|
1850
|
+
$("[name="+i+"]",formid).val(rowdata[i]);
|
1851
|
+
}
|
1852
|
+
}
|
1853
|
+
}
|
1854
|
+
});
|
1855
|
+
},
|
1856
|
+
FormToGrid : function(rowid, formid, mode, position){
|
1857
|
+
return this.each(function() {
|
1858
|
+
var $t = this;
|
1859
|
+
if(!$t.grid) { return; }
|
1860
|
+
if(!mode) { mode = 'set'; }
|
1861
|
+
if(!position) { position = 'first'; }
|
1862
|
+
var fields = $(formid).serializeArray();
|
1863
|
+
var griddata = {};
|
1864
|
+
$.each(fields, function(i, field){
|
1865
|
+
griddata[field.name] = field.value;
|
1866
|
+
});
|
1867
|
+
if(mode=='add') { $($t).jqGrid("addRowData",rowid,griddata, position); }
|
1868
|
+
else if(mode=='set') { $($t).jqGrid("setRowData",rowid,griddata); }
|
1869
|
+
});
|
1870
|
+
}
|
1871
|
+
});
|
1872
|
+
})(jQuery);
|