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,201 @@
|
|
1
|
+
;(function($){
|
2
|
+
/*
|
3
|
+
* jqGrid extension for constructing Grid Data from external file
|
4
|
+
* Tony Tomov tony@trirand.com
|
5
|
+
* http://trirand.com/blog/
|
6
|
+
* Dual licensed under the MIT and GPL licenses:
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
* http://www.gnu.org/licenses/gpl-2.0.html
|
9
|
+
**/
|
10
|
+
$.jgrid.extend({
|
11
|
+
jqGridImport : function(o) {
|
12
|
+
o = $.extend({
|
13
|
+
imptype : "xml", // xml, json, xmlstring, jsonstring
|
14
|
+
impstring: "",
|
15
|
+
impurl: "",
|
16
|
+
mtype: "GET",
|
17
|
+
impData : {},
|
18
|
+
xmlGrid :{
|
19
|
+
config : "roots>grid",
|
20
|
+
data: "roots>rows"
|
21
|
+
},
|
22
|
+
jsonGrid :{
|
23
|
+
config : "grid",
|
24
|
+
data: "data"
|
25
|
+
},
|
26
|
+
ajaxOptions :{}
|
27
|
+
}, o || {});
|
28
|
+
return this.each(function(){
|
29
|
+
var $t = this;
|
30
|
+
var XmlConvert = function (xml,o) {
|
31
|
+
var cnfg = $(o.xmlGrid.config,xml)[0];
|
32
|
+
var xmldata = $(o.xmlGrid.data,xml)[0], jstr, jstr1;
|
33
|
+
if(xmlJsonClass.xml2json && $.jgrid.parse) {
|
34
|
+
jstr = xmlJsonClass.xml2json(cnfg," ");
|
35
|
+
jstr = $.jgrid.parse(jstr);
|
36
|
+
for(var key in jstr) {
|
37
|
+
if(jstr.hasOwnProperty(key)) {
|
38
|
+
jstr1=jstr[key];
|
39
|
+
}
|
40
|
+
}
|
41
|
+
if(xmldata) {
|
42
|
+
// save the datatype
|
43
|
+
var svdatatype = jstr.grid.datatype;
|
44
|
+
jstr.grid.datatype = 'xmlstring';
|
45
|
+
jstr.grid.datastr = xml;
|
46
|
+
$($t).jqGrid( jstr1 ).jqGrid("setGridParam",{datatype:svdatatype});
|
47
|
+
} else {
|
48
|
+
$($t).jqGrid( jstr1 );
|
49
|
+
}
|
50
|
+
jstr = null;jstr1=null;
|
51
|
+
} else {
|
52
|
+
alert("xml2json or parse are not present");
|
53
|
+
}
|
54
|
+
};
|
55
|
+
var JsonConvert = function (jsonstr,o){
|
56
|
+
if (jsonstr && typeof jsonstr == 'string') {
|
57
|
+
var json = $.jgrid.parse(jsonstr);
|
58
|
+
var gprm = json[o.jsonGrid.config];
|
59
|
+
var jdata = json[o.jsonGrid.data];
|
60
|
+
if(jdata) {
|
61
|
+
var svdatatype = gprm.datatype;
|
62
|
+
gprm.datatype = 'jsonstring';
|
63
|
+
gprm.datastr = jdata;
|
64
|
+
$($t).jqGrid( gprm ).jqGrid("setGridParam",{datatype:svdatatype});
|
65
|
+
} else {
|
66
|
+
$($t).jqGrid( gprm );
|
67
|
+
}
|
68
|
+
}
|
69
|
+
};
|
70
|
+
switch (o.imptype){
|
71
|
+
case 'xml':
|
72
|
+
$.ajax($.extend({
|
73
|
+
url:o.impurl,
|
74
|
+
type:o.mtype,
|
75
|
+
data: o.impData,
|
76
|
+
dataType:"xml",
|
77
|
+
complete: function(xml,stat) {
|
78
|
+
if(stat == 'success') {
|
79
|
+
XmlConvert(xml.responseXML,o);
|
80
|
+
if($.isFunction(o.importComplete)) {
|
81
|
+
o.importComplete(xml);
|
82
|
+
}
|
83
|
+
}
|
84
|
+
xml=null;
|
85
|
+
}
|
86
|
+
}, o.ajaxOptions));
|
87
|
+
break;
|
88
|
+
case 'xmlstring' :
|
89
|
+
// we need to make just the conversion and use the same code as xml
|
90
|
+
if(o.impstring && typeof o.impstring == 'string') {
|
91
|
+
var xmld = $.jgrid.stringToDoc(o.impstring);
|
92
|
+
if(xmld) {
|
93
|
+
XmlConvert(xmld,o);
|
94
|
+
if($.isFunction(o.importComplete)) {
|
95
|
+
o.importComplete(xmld);
|
96
|
+
}
|
97
|
+
o.impstring = null;
|
98
|
+
}
|
99
|
+
xmld = null;
|
100
|
+
}
|
101
|
+
break;
|
102
|
+
case 'json':
|
103
|
+
$.ajax($.extend({
|
104
|
+
url:o.impurl,
|
105
|
+
type:o.mtype,
|
106
|
+
data: o.impData,
|
107
|
+
dataType:"json",
|
108
|
+
complete: function(json,stat) {
|
109
|
+
if(stat == 'success') {
|
110
|
+
JsonConvert(json.responseText,o );
|
111
|
+
if($.isFunction(o.importComplete)) {
|
112
|
+
o.importComplete(json);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
json=null;
|
116
|
+
}
|
117
|
+
}, o.ajaxOptions ));
|
118
|
+
break;
|
119
|
+
case 'jsonstring' :
|
120
|
+
if(o.impstring && typeof o.impstring == 'string') {
|
121
|
+
JsonConvert(o.impstring,o );
|
122
|
+
if($.isFunction(o.importComplete)) {
|
123
|
+
o.importComplete(o.impstring);
|
124
|
+
}
|
125
|
+
o.impstring = null;
|
126
|
+
}
|
127
|
+
break;
|
128
|
+
}
|
129
|
+
});
|
130
|
+
},
|
131
|
+
jqGridExport : function(o) {
|
132
|
+
o = $.extend({
|
133
|
+
exptype : "xmlstring",
|
134
|
+
root: "grid",
|
135
|
+
ident: "\t"
|
136
|
+
}, o || {});
|
137
|
+
var ret = null;
|
138
|
+
this.each(function () {
|
139
|
+
if(!this.grid) { return;}
|
140
|
+
var gprm = $.extend({},$(this).jqGrid("getGridParam"));
|
141
|
+
// we need to check for:
|
142
|
+
// 1.multiselect, 2.subgrid 3. treegrid and remove the unneded columns from colNames
|
143
|
+
if(gprm.rownumbers) {
|
144
|
+
gprm.colNames.splice(0,1);
|
145
|
+
gprm.colModel.splice(0,1);
|
146
|
+
}
|
147
|
+
if(gprm.multiselect) {
|
148
|
+
gprm.colNames.splice(0,1);
|
149
|
+
gprm.colModel.splice(0,1);
|
150
|
+
}
|
151
|
+
if(gprm.subGrid) {
|
152
|
+
gprm.colNames.splice(0,1);
|
153
|
+
gprm.colModel.splice(0,1);
|
154
|
+
}
|
155
|
+
gprm.knv = null;
|
156
|
+
if(gprm.treeGrid) {
|
157
|
+
for (var key in gprm.treeReader) {
|
158
|
+
if(gprm.treeReader.hasOwnProperty(key)) {
|
159
|
+
gprm.colNames.splice(gprm.colNames.length-1);
|
160
|
+
gprm.colModel.splice(gprm.colModel.length-1);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
switch (o.exptype) {
|
165
|
+
case 'xmlstring' :
|
166
|
+
ret = "<"+o.root+">"+xmlJsonClass.json2xml(gprm,o.ident)+"</"+o.root+">";
|
167
|
+
break;
|
168
|
+
case 'jsonstring' :
|
169
|
+
ret = "{"+ xmlJsonClass.toJson(gprm,o.root,o.ident)+"}";
|
170
|
+
if(gprm.postData.filters !== undefined) {
|
171
|
+
ret=ret.replace(/filters":"/,'filters":');
|
172
|
+
ret=ret.replace(/}]}"/,'}]}');
|
173
|
+
}
|
174
|
+
break;
|
175
|
+
}
|
176
|
+
});
|
177
|
+
return ret;
|
178
|
+
},
|
179
|
+
excelExport : function(o) {
|
180
|
+
o = $.extend({
|
181
|
+
exptype : "remote",
|
182
|
+
url : null,
|
183
|
+
oper: "oper",
|
184
|
+
tag: "excel",
|
185
|
+
exportOptions : {}
|
186
|
+
}, o || {});
|
187
|
+
return this.each(function(){
|
188
|
+
if(!this.grid) { return;}
|
189
|
+
var url;
|
190
|
+
if(o.exptype == "remote") {
|
191
|
+
var pdata = $.extend({},this.p.postData);
|
192
|
+
pdata[o.oper] = o.tag;
|
193
|
+
var params = jQuery.param(pdata);
|
194
|
+
if(o.url.indexOf("?") != -1) { url = o.url+"&"+params; }
|
195
|
+
else { url = o.url+"?"+params; }
|
196
|
+
window.location = url;
|
197
|
+
}
|
198
|
+
});
|
199
|
+
}
|
200
|
+
});
|
201
|
+
})(jQuery);
|
@@ -0,0 +1,250 @@
|
|
1
|
+
;(function($){
|
2
|
+
/**
|
3
|
+
* jqGrid extension for manipulating 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
|
+
$.jgrid.extend({
|
11
|
+
//Editing
|
12
|
+
editRow : function(rowid,keys,oneditfunc,succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) {
|
13
|
+
return this.each(function(){
|
14
|
+
var $t = this, nm, tmp, editable, cnt=0, focus=null, svr={}, ind,cm;
|
15
|
+
if (!$t.grid ) { return; }
|
16
|
+
ind = $($t).jqGrid("getInd",rowid,true);
|
17
|
+
if( ind === false ) {return;}
|
18
|
+
editable = $(ind).attr("editable") || "0";
|
19
|
+
if (editable == "0" && !$(ind).hasClass("not-editable-row")) {
|
20
|
+
cm = $t.p.colModel;
|
21
|
+
$('td',ind).each( function(i) {
|
22
|
+
nm = cm[i].name;
|
23
|
+
var treeg = $t.p.treeGrid===true && nm == $t.p.ExpandColumn;
|
24
|
+
if(treeg) { tmp = $("span:first",this).html();}
|
25
|
+
else {
|
26
|
+
try {
|
27
|
+
tmp = $.unformat(this,{rowId:rowid, colModel:cm[i]},i);
|
28
|
+
} catch (_) {
|
29
|
+
tmp = $(this).html();
|
30
|
+
}
|
31
|
+
}
|
32
|
+
if ( nm != 'cb' && nm != 'subgrid' && nm != 'rn') {
|
33
|
+
if($t.p.autoencode) { tmp = $.jgrid.htmlDecode(tmp); }
|
34
|
+
svr[nm]=tmp;
|
35
|
+
if(cm[i].editable===true) {
|
36
|
+
if(focus===null) { focus = i; }
|
37
|
+
if (treeg) { $("span:first",this).html(""); }
|
38
|
+
else { $(this).html(""); }
|
39
|
+
var opt = $.extend({},cm[i].editoptions || {},{id:rowid+"_"+nm,name:nm});
|
40
|
+
if(!cm[i].edittype) { cm[i].edittype = "text"; }
|
41
|
+
var elc = createEl(cm[i].edittype,opt,tmp,true,$.extend({},$.jgrid.ajaxOptions,$t.p.ajaxSelectOptions || {}));
|
42
|
+
$(elc).addClass("editable");
|
43
|
+
if(treeg) { $("span:first",this).append(elc); }
|
44
|
+
else { $(this).append(elc); }
|
45
|
+
//Again IE
|
46
|
+
if(cm[i].edittype == "select" && cm[i].editoptions.multiple===true && $.browser.msie) {
|
47
|
+
$(elc).width($(elc).width());
|
48
|
+
}
|
49
|
+
cnt++;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
});
|
53
|
+
if(cnt > 0) {
|
54
|
+
svr.id = rowid; $t.p.savedRow.push(svr);
|
55
|
+
$(ind).attr("editable","1");
|
56
|
+
$("td:eq("+focus+") input",ind).focus();
|
57
|
+
if(keys===true) {
|
58
|
+
$(ind).bind("keydown",function(e) {
|
59
|
+
if (e.keyCode === 27) {$($t).jqGrid("restoreRow",rowid, afterrestorefunc);}
|
60
|
+
if (e.keyCode === 13) {
|
61
|
+
var ta = e.target;
|
62
|
+
if(ta.tagName == 'TEXTAREA') { return true; }
|
63
|
+
$($t).jqGrid("saveRow",rowid,succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc );
|
64
|
+
return false;
|
65
|
+
}
|
66
|
+
e.stopPropagation();
|
67
|
+
});
|
68
|
+
}
|
69
|
+
if( $.isFunction(oneditfunc)) { oneditfunc(rowid); }
|
70
|
+
}
|
71
|
+
}
|
72
|
+
});
|
73
|
+
},
|
74
|
+
saveRow : function(rowid, succesfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) {
|
75
|
+
return this.each(function(){
|
76
|
+
var $t = this, nm, tmp={}, tmp2={}, editable, fr, cv, ind;
|
77
|
+
if (!$t.grid ) { return; }
|
78
|
+
ind = $($t).jqGrid("getInd",rowid,true);
|
79
|
+
if(ind === false) {return;}
|
80
|
+
editable = $(ind).attr("editable");
|
81
|
+
url = url ? url : $t.p.editurl;
|
82
|
+
if (editable==="1") {
|
83
|
+
var cm;
|
84
|
+
$("td",ind).each(function(i) {
|
85
|
+
cm = $t.p.colModel[i];
|
86
|
+
nm = cm.name;
|
87
|
+
if ( nm != 'cb' && nm != 'subgrid' && cm.editable===true && nm != 'rn') {
|
88
|
+
switch (cm.edittype) {
|
89
|
+
case "checkbox":
|
90
|
+
var cbv = ["Yes","No"];
|
91
|
+
if(cm.editoptions ) {
|
92
|
+
cbv = cm.editoptions.value.split(":");
|
93
|
+
}
|
94
|
+
tmp[nm]= $("input",this).attr("checked") ? cbv[0] : cbv[1];
|
95
|
+
break;
|
96
|
+
case 'text':
|
97
|
+
case 'password':
|
98
|
+
case 'textarea':
|
99
|
+
case "button" :
|
100
|
+
tmp[nm]=$("input, textarea",this).val();
|
101
|
+
break;
|
102
|
+
case 'select':
|
103
|
+
if(!cm.editoptions.multiple) {
|
104
|
+
tmp[nm] = $("select>option:selected",this).val();
|
105
|
+
tmp2[nm] = $("select>option:selected", this).text();
|
106
|
+
} else {
|
107
|
+
var sel = $("select",this), selectedText = [];
|
108
|
+
tmp[nm] = $(sel).val();
|
109
|
+
if(tmp[nm]) { tmp[nm]= tmp[nm].join(","); } else { tmp[nm] =""; }
|
110
|
+
$("select > option:selected",this).each(
|
111
|
+
function(i,selected){
|
112
|
+
selectedText[i] = $(selected).text();
|
113
|
+
}
|
114
|
+
);
|
115
|
+
tmp2[nm] = selectedText.join(",");
|
116
|
+
}
|
117
|
+
if(cm.formatter && cm.formatter == 'select') { tmp2={}; }
|
118
|
+
break;
|
119
|
+
case 'custom' :
|
120
|
+
try {
|
121
|
+
if(cm.editoptions && $.isFunction(cm.editoptions.custom_value)) {
|
122
|
+
tmp[nm] = cm.editoptions.custom_value($(".customelement",this),'get');
|
123
|
+
if (tmp[nm] === undefined) { throw "e2"; }
|
124
|
+
} else { throw "e1"; }
|
125
|
+
} catch (e) {
|
126
|
+
if (e=="e1") { info_dialog(jQuery.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,jQuery.jgrid.edit.bClose); }
|
127
|
+
if (e=="e2") { info_dialog(jQuery.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,jQuery.jgrid.edit.bClose); }
|
128
|
+
else { info_dialog(jQuery.jgrid.errors.errcap,e.message,jQuery.jgrid.edit.bClose); }
|
129
|
+
}
|
130
|
+
break;
|
131
|
+
}
|
132
|
+
cv = checkValues(tmp[nm],i,$t);
|
133
|
+
if(cv[0] === false) {
|
134
|
+
cv[1] = tmp[nm] + " " + cv[1];
|
135
|
+
return false;
|
136
|
+
}
|
137
|
+
if($t.p.autoencode) { tmp[nm] = $.jgrid.htmlEncode(tmp[nm]); }
|
138
|
+
}
|
139
|
+
});
|
140
|
+
if (cv[0] === false){
|
141
|
+
try {
|
142
|
+
var positions = findPos($("#"+$.jgrid.jqID(rowid), $t.grid.bDiv)[0]);
|
143
|
+
info_dialog($.jgrid.errors.errcap,cv[1],$.jgrid.edit.bClose,{left:positions[0],top:positions[1]});
|
144
|
+
} catch (e) {
|
145
|
+
alert(cv[1]);
|
146
|
+
}
|
147
|
+
return;
|
148
|
+
}
|
149
|
+
if(tmp) {
|
150
|
+
var idname, opers, oper;
|
151
|
+
opers = $t.p.prmNames;
|
152
|
+
oper = opers.oper;
|
153
|
+
idname = opers.id;
|
154
|
+
tmp[oper] = opers.editoper;
|
155
|
+
tmp[idname] = rowid;
|
156
|
+
if(typeof($t.p.inlineData) == 'undefined') { $t.p.inlineData ={}; }
|
157
|
+
if(typeof(extraparam) == 'undefined') { extraparam ={}; }
|
158
|
+
tmp = $.extend({},tmp,$t.p.inlineData,extraparam);
|
159
|
+
}
|
160
|
+
if (url == 'clientArray') {
|
161
|
+
tmp = $.extend({},tmp, tmp2);
|
162
|
+
if($t.p.autoencode) {
|
163
|
+
$.each(tmp,function(n,v){
|
164
|
+
tmp[n] = $.jgrid.htmlDecode(v);
|
165
|
+
});
|
166
|
+
}
|
167
|
+
var resp = $($t).jqGrid("setRowData",rowid,tmp);
|
168
|
+
$(ind).attr("editable","0");
|
169
|
+
for( var k=0;k<$t.p.savedRow.length;k++) {
|
170
|
+
if( $t.p.savedRow[k].id == rowid) {fr = k; break;}
|
171
|
+
}
|
172
|
+
if(fr >= 0) { $t.p.savedRow.splice(fr,1); }
|
173
|
+
if( $.isFunction(aftersavefunc) ) { aftersavefunc(rowid,resp); }
|
174
|
+
} else {
|
175
|
+
$("#lui_"+$t.p.id).show();
|
176
|
+
$.ajax($.extend({
|
177
|
+
url:url,
|
178
|
+
data: $.isFunction($t.p.serializeRowData) ? $t.p.serializeRowData(tmp) : tmp,
|
179
|
+
type: "POST",
|
180
|
+
complete: function(res,stat){
|
181
|
+
$("#lui_"+$t.p.id).hide();
|
182
|
+
if (stat === "success"){
|
183
|
+
var ret;
|
184
|
+
if( $.isFunction(succesfunc)) { ret = succesfunc(res);}
|
185
|
+
else { ret = true; }
|
186
|
+
if (ret===true) {
|
187
|
+
if($t.p.autoencode) {
|
188
|
+
$.each(tmp,function(n,v){
|
189
|
+
tmp[n] = $.jgrid.htmlDecode(v);
|
190
|
+
});
|
191
|
+
}
|
192
|
+
tmp = $.extend({},tmp, tmp2);
|
193
|
+
$($t).jqGrid("setRowData",rowid,tmp);
|
194
|
+
$(ind).attr("editable","0");
|
195
|
+
for( var k=0;k<$t.p.savedRow.length;k++) {
|
196
|
+
if( $t.p.savedRow[k].id == rowid) {fr = k; break;}
|
197
|
+
}
|
198
|
+
if(fr >= 0) { $t.p.savedRow.splice(fr,1); }
|
199
|
+
if( $.isFunction(aftersavefunc) ) { aftersavefunc(rowid,res); }
|
200
|
+
} else { $($t).jqGrid("restoreRow",rowid, afterrestorefunc); }
|
201
|
+
}
|
202
|
+
},
|
203
|
+
error:function(res,stat){
|
204
|
+
$("#lui_"+$t.p.id).hide();
|
205
|
+
if($.isFunction(errorfunc) ) {
|
206
|
+
errorfunc(rowid, res, stat);
|
207
|
+
} else {
|
208
|
+
alert("Error Row: "+rowid+" Result: " +res.status+":"+res.statusText+" Status: "+stat);
|
209
|
+
}
|
210
|
+
$($t).jqGrid("restoreRow",rowid, afterrestorefunc);
|
211
|
+
}
|
212
|
+
}, $.jgrid.ajaxOptions, $t.p.ajaxRowOptions || {}));
|
213
|
+
}
|
214
|
+
$(ind).unbind("keydown");
|
215
|
+
}
|
216
|
+
});
|
217
|
+
},
|
218
|
+
restoreRow : function(rowid, afterrestorefunc) {
|
219
|
+
return this.each(function(){
|
220
|
+
var $t= this, fr, ind, ares={};
|
221
|
+
if (!$t.grid ) { return; }
|
222
|
+
ind = $($t).jqGrid("getInd",rowid,true);
|
223
|
+
if(ind === false) {return;}
|
224
|
+
for( var k=0;k<$t.p.savedRow.length;k++) {
|
225
|
+
if( $t.p.savedRow[k].id == rowid) {fr = k; break;}
|
226
|
+
}
|
227
|
+
if(fr >= 0) {
|
228
|
+
if($.isFunction($.fn.datepicker)) {
|
229
|
+
try {
|
230
|
+
$("input.hasDatepicker","#"+$.jgrid.jqID(ind.id)).datepicker('hide');
|
231
|
+
} catch (e) {}
|
232
|
+
}
|
233
|
+
$.each($t.p.colModel, function(i,n){
|
234
|
+
if(this.editable === true && this.name in $t.p.savedRow[fr]) {
|
235
|
+
ares[this.name] = $t.p.savedRow[fr][this.name];
|
236
|
+
}
|
237
|
+
});
|
238
|
+
$($t).jqGrid("setRowData",rowid,ares);
|
239
|
+
$(ind).attr("editable","0").unbind("keydown");
|
240
|
+
$t.p.savedRow.splice(fr,1);
|
241
|
+
}
|
242
|
+
if ($.isFunction(afterrestorefunc))
|
243
|
+
{
|
244
|
+
afterrestorefunc(rowid);
|
245
|
+
}
|
246
|
+
});
|
247
|
+
}
|
248
|
+
//end inline edit
|
249
|
+
});
|
250
|
+
})(jQuery);
|