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,503 @@
|
|
1
|
+
;(function($){
|
2
|
+
/*
|
3
|
+
**
|
4
|
+
* jqGrid addons using jQuery UI
|
5
|
+
* Author: Mark Williams
|
6
|
+
* Dual licensed under the MIT and GPL licenses:
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
* http://www.gnu.org/licenses/gpl-2.0.html
|
9
|
+
* depends on jQuery UI
|
10
|
+
**/
|
11
|
+
if ($.browser.msie && $.browser.version==8) {
|
12
|
+
$.expr[":"].hidden = function(elem) {
|
13
|
+
return elem.offsetWidth === 0 || elem.offsetHeight === 0 ||
|
14
|
+
elem.style.display == "none";
|
15
|
+
};
|
16
|
+
}
|
17
|
+
// requiere load multiselect before grid
|
18
|
+
$.jgrid._multiselect = false;
|
19
|
+
if($.ui) {
|
20
|
+
if ($.ui.multiselect ) {
|
21
|
+
if($.ui.multiselect.prototype._setSelected) {
|
22
|
+
var setSelected = $.ui.multiselect.prototype._setSelected;
|
23
|
+
$.ui.multiselect.prototype._setSelected = function(item,selected) {
|
24
|
+
var ret = setSelected.call(this,item,selected);
|
25
|
+
if (selected && this.selectedList) {
|
26
|
+
var elt = this.element;
|
27
|
+
this.selectedList.find('li').each(function() {
|
28
|
+
if ($(this).data('optionLink')) {
|
29
|
+
$(this).data('optionLink').remove().appendTo(elt);
|
30
|
+
}
|
31
|
+
});
|
32
|
+
}
|
33
|
+
return ret;
|
34
|
+
};
|
35
|
+
}
|
36
|
+
if($.ui.multiselect.prototype.destroy) {
|
37
|
+
$.ui.multiselect.prototype.destroy = function() {
|
38
|
+
this.element.show();
|
39
|
+
this.container.remove();
|
40
|
+
if ($.Widget === undefined) {
|
41
|
+
$.widget.prototype.destroy.apply(this, arguments);
|
42
|
+
} else {
|
43
|
+
$.Widget.prototype.destroy.apply(this, arguments);
|
44
|
+
}
|
45
|
+
};
|
46
|
+
}
|
47
|
+
$.jgrid._multiselect = true;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
$.jgrid.extend({
|
52
|
+
sortableColumns : function (tblrow)
|
53
|
+
{
|
54
|
+
return this.each(function (){
|
55
|
+
var ts = this;
|
56
|
+
function start() {ts.p.disableClick = true;}
|
57
|
+
var sortable_opts = {
|
58
|
+
"tolerance" : "pointer",
|
59
|
+
"axis" : "x",
|
60
|
+
"scrollSensitivity": "1",
|
61
|
+
"items": '>th:not(:has(#jqgh_cb,#jqgh_rn,#jqgh_subgrid),:hidden)',
|
62
|
+
"placeholder": {
|
63
|
+
element: function(item) {
|
64
|
+
var el = $(document.createElement(item[0].nodeName))
|
65
|
+
.addClass(item[0].className+" ui-sortable-placeholder ui-state-highlight")
|
66
|
+
.removeClass("ui-sortable-helper")[0];
|
67
|
+
return el;
|
68
|
+
},
|
69
|
+
update: function(self, p) {
|
70
|
+
p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10));
|
71
|
+
p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10));
|
72
|
+
}
|
73
|
+
},
|
74
|
+
"update": function(event, ui) {
|
75
|
+
var p = $(ui.item).parent();
|
76
|
+
var th = $(">th", p);
|
77
|
+
var colModel = ts.p.colModel;
|
78
|
+
var cmMap = {};
|
79
|
+
$.each(colModel, function(i) { cmMap[this.name]=i; });
|
80
|
+
var permutation = [];
|
81
|
+
th.each(function(i) {
|
82
|
+
var id = $(">div", this).get(0).id.replace(/^jqgh_/, "");
|
83
|
+
if (id in cmMap) {
|
84
|
+
permutation.push(cmMap[id]);
|
85
|
+
}
|
86
|
+
});
|
87
|
+
|
88
|
+
$(ts).jqGrid("remapColumns",permutation, true, true);
|
89
|
+
if ($.isFunction(ts.p.sortable.update)) {
|
90
|
+
ts.p.sortable.update(permutation);
|
91
|
+
}
|
92
|
+
setTimeout(function(){ts.p.disableClick=false;}, 50);
|
93
|
+
}
|
94
|
+
};
|
95
|
+
if (ts.p.sortable.options) {
|
96
|
+
$.extend(sortable_opts, ts.p.sortable.options);
|
97
|
+
} else if ($.isFunction(ts.p.sortable)) {
|
98
|
+
ts.p.sortable = { "update" : ts.p.sortable };
|
99
|
+
}
|
100
|
+
if (sortable_opts.start) {
|
101
|
+
var s = sortable_opts.start;
|
102
|
+
sortable_opts.start = function(e,ui) {
|
103
|
+
start();
|
104
|
+
s.call(this,e,ui);
|
105
|
+
};
|
106
|
+
} else {
|
107
|
+
sortable_opts.start = start;
|
108
|
+
}
|
109
|
+
if (ts.p.sortable.exclude) {
|
110
|
+
sortable_opts.items += ":not("+ts.p.sortable.exclude+")";
|
111
|
+
}
|
112
|
+
tblrow.sortable(sortable_opts).data("sortable").floating = true;
|
113
|
+
});
|
114
|
+
},
|
115
|
+
columnChooser : function(opts) {
|
116
|
+
var self = this;
|
117
|
+
if($("#colchooser_"+self[0].p.id).length ) { return; }
|
118
|
+
var selector = $('<div id="colchooser_'+self[0].p.id+'" style="position:relative;overflow:hidden"><div><select multiple="multiple"></select></div></div>');
|
119
|
+
var select = $('select', selector);
|
120
|
+
|
121
|
+
opts = $.extend({
|
122
|
+
"width" : 420,
|
123
|
+
"height" : 240,
|
124
|
+
"classname" : null,
|
125
|
+
"done" : function(perm) { if (perm) { self.jqGrid("remapColumns", perm, true); } },
|
126
|
+
/* msel is either the name of a ui widget class that
|
127
|
+
extends a multiselect, or a function that supports
|
128
|
+
creating a multiselect object (with no argument,
|
129
|
+
or when passed an object), and destroying it (when
|
130
|
+
passed the string "destroy"). */
|
131
|
+
"msel" : "multiselect",
|
132
|
+
/* "msel_opts" : {}, */
|
133
|
+
|
134
|
+
/* dlog is either the name of a ui widget class that
|
135
|
+
behaves in a dialog-like way, or a function, that
|
136
|
+
supports creating a dialog (when passed dlog_opts)
|
137
|
+
or destroying a dialog (when passed the string
|
138
|
+
"destroy")
|
139
|
+
*/
|
140
|
+
"dlog" : "dialog",
|
141
|
+
|
142
|
+
/* dlog_opts is either an option object to be passed
|
143
|
+
to "dlog", or (more likely) a function that creates
|
144
|
+
the options object.
|
145
|
+
The default produces a suitable options object for
|
146
|
+
ui.dialog */
|
147
|
+
"dlog_opts" : function(opts) {
|
148
|
+
var buttons = {};
|
149
|
+
buttons[opts.bSubmit] = function() {
|
150
|
+
opts.apply_perm();
|
151
|
+
opts.cleanup(false);
|
152
|
+
};
|
153
|
+
buttons[opts.bCancel] = function() {
|
154
|
+
opts.cleanup(true);
|
155
|
+
};
|
156
|
+
return {
|
157
|
+
"buttons": buttons,
|
158
|
+
"close": function() {
|
159
|
+
opts.cleanup(true);
|
160
|
+
},
|
161
|
+
"modal" : false,
|
162
|
+
"resizable": false,
|
163
|
+
"width": opts.width+20
|
164
|
+
};
|
165
|
+
},
|
166
|
+
/* Function to get the permutation array, and pass it to the
|
167
|
+
"done" function */
|
168
|
+
"apply_perm" : function() {
|
169
|
+
$('option',select).each(function(i) {
|
170
|
+
if (this.selected) {
|
171
|
+
self.jqGrid("showCol", colModel[this.value].name);
|
172
|
+
} else {
|
173
|
+
self.jqGrid("hideCol", colModel[this.value].name);
|
174
|
+
}
|
175
|
+
});
|
176
|
+
|
177
|
+
var perm = [];
|
178
|
+
//fixedCols.slice(0);
|
179
|
+
$('option[selected]',select).each(function() { perm.push(parseInt(this.value,10)); });
|
180
|
+
$.each(perm, function() { delete colMap[colModel[parseInt(this,10)].name]; });
|
181
|
+
$.each(colMap, function() {
|
182
|
+
var ti = parseInt(this,10);
|
183
|
+
perm = insert(perm,ti,ti);
|
184
|
+
});
|
185
|
+
if (opts.done) {
|
186
|
+
opts.done.call(self, perm);
|
187
|
+
}
|
188
|
+
},
|
189
|
+
/* Function to cleanup the dialog, and select. Also calls the
|
190
|
+
done function with no permutation (to indicate that the
|
191
|
+
columnChooser was aborted */
|
192
|
+
"cleanup" : function(calldone) {
|
193
|
+
call(opts.dlog, selector, 'destroy');
|
194
|
+
call(opts.msel, select, 'destroy');
|
195
|
+
selector.remove();
|
196
|
+
if (calldone && opts.done) {
|
197
|
+
opts.done.call(self);
|
198
|
+
}
|
199
|
+
},
|
200
|
+
"msel_opts" : {}
|
201
|
+
}, $.jgrid.col, opts || {});
|
202
|
+
if($.ui) {
|
203
|
+
if ($.ui.multiselect ) {
|
204
|
+
if(opts.msel == "multiselect") {
|
205
|
+
if(!$.jgrid._multiselect) {
|
206
|
+
// should be in language file
|
207
|
+
alert("Multiselect plugin loaded after jqGrid. Please load the plugin before the jqGrid!");
|
208
|
+
return;
|
209
|
+
}
|
210
|
+
opts.msel_opts = $.extend($.ui.multiselect.defaults,opts.msel_opts);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
}
|
214
|
+
if (opts.caption) {
|
215
|
+
selector.attr("title", opts.caption);
|
216
|
+
}
|
217
|
+
if (opts.classname) {
|
218
|
+
selector.addClass(opts.classname);
|
219
|
+
select.addClass(opts.classname);
|
220
|
+
}
|
221
|
+
if (opts.width) {
|
222
|
+
$(">div",selector).css({"width": opts.width,"margin":"0 auto"});
|
223
|
+
select.css("width", opts.width);
|
224
|
+
}
|
225
|
+
if (opts.height) {
|
226
|
+
$(">div",selector).css("height", opts.height);
|
227
|
+
select.css("height", opts.height - 10);
|
228
|
+
}
|
229
|
+
var colModel = self.jqGrid("getGridParam", "colModel");
|
230
|
+
var colNames = self.jqGrid("getGridParam", "colNames");
|
231
|
+
var colMap = {}, fixedCols = [];
|
232
|
+
|
233
|
+
select.empty();
|
234
|
+
$.each(colModel, function(i) {
|
235
|
+
colMap[this.name] = i;
|
236
|
+
if (this.hidedlg) {
|
237
|
+
if (!this.hidden) {
|
238
|
+
fixedCols.push(i);
|
239
|
+
}
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
|
243
|
+
select.append("<option value='"+i+"' "+
|
244
|
+
(this.hidden?"":"selected='selected'")+">"+colNames[i]+"</option>");
|
245
|
+
});
|
246
|
+
function insert(perm,i,v) {
|
247
|
+
if(i>=0){
|
248
|
+
var a = perm.slice();
|
249
|
+
var b = a.splice(i,Math.max(perm.length-i,i));
|
250
|
+
if(i>perm.length) { i = perm.length; }
|
251
|
+
a[i] = v;
|
252
|
+
return a.concat(b);
|
253
|
+
}
|
254
|
+
}
|
255
|
+
function call(fn, obj) {
|
256
|
+
if (!fn) { return; }
|
257
|
+
if (typeof fn == 'string') {
|
258
|
+
if ($.fn[fn]) {
|
259
|
+
$.fn[fn].apply(obj, $.makeArray(arguments).slice(2));
|
260
|
+
}
|
261
|
+
} else if ($.isFunction(fn)) {
|
262
|
+
fn.apply(obj, $.makeArray(arguments).slice(2));
|
263
|
+
}
|
264
|
+
}
|
265
|
+
|
266
|
+
var dopts = $.isFunction(opts.dlog_opts) ? opts.dlog_opts.call(self, opts) : opts.dlog_opts;
|
267
|
+
call(opts.dlog, selector, dopts);
|
268
|
+
var mopts = $.isFunction(opts.msel_opts) ? opts.msel_opts.call(self, opts) : opts.msel_opts;
|
269
|
+
call(opts.msel, select, mopts);
|
270
|
+
},
|
271
|
+
sortableRows : function (opts) {
|
272
|
+
// Can accept all sortable options and events
|
273
|
+
return this.each(function(){
|
274
|
+
var $t = this;
|
275
|
+
if(!$t.grid) { return; }
|
276
|
+
// Currently we disable a treeGrid sortable
|
277
|
+
if($t.p.treeGrid) { return; }
|
278
|
+
if($.fn.sortable) {
|
279
|
+
opts = $.extend({
|
280
|
+
"cursor":"move",
|
281
|
+
"axis" : "y",
|
282
|
+
"items": ".jqgrow"
|
283
|
+
},
|
284
|
+
opts || {});
|
285
|
+
if(opts.start && $.isFunction(opts.start)) {
|
286
|
+
opts._start_ = opts.start;
|
287
|
+
delete opts.start;
|
288
|
+
} else {opts._start_=false;}
|
289
|
+
if(opts.update && $.isFunction(opts.update)) {
|
290
|
+
opts._update_ = opts.update;
|
291
|
+
delete opts.update;
|
292
|
+
} else {opts._update_ = false;}
|
293
|
+
opts.start = function(ev,ui) {
|
294
|
+
$(ui.item).css("border-width","0px");
|
295
|
+
$("td",ui.item).each(function(i){
|
296
|
+
this.style.width = $t.grid.cols[i].style.width;
|
297
|
+
});
|
298
|
+
if($t.p.subGrid) {
|
299
|
+
var subgid = $(ui.item).attr("id");
|
300
|
+
try {
|
301
|
+
$($t).jqGrid('collapseSubGridRow',subgid);
|
302
|
+
} catch (e) {}
|
303
|
+
}
|
304
|
+
if(opts._start_) {
|
305
|
+
opts._start_.apply(this,[ev,ui]);
|
306
|
+
}
|
307
|
+
};
|
308
|
+
opts.update = function (ev,ui) {
|
309
|
+
$(ui.item).css("border-width","");
|
310
|
+
$t.updateColumns();
|
311
|
+
if($t.p.rownumbers === true) {
|
312
|
+
$("td.jqgrid-rownum",$t.rows).each(function(i){
|
313
|
+
$(this).html(i+1);
|
314
|
+
});
|
315
|
+
}
|
316
|
+
if(opts._update_) {
|
317
|
+
opts._update_.apply(this,[ev,ui]);
|
318
|
+
}
|
319
|
+
};
|
320
|
+
$("tbody:first",$t).sortable(opts);
|
321
|
+
$("tbody:first",$t).disableSelection();
|
322
|
+
}
|
323
|
+
});
|
324
|
+
},
|
325
|
+
gridDnD : function(opts) {
|
326
|
+
return this.each(function(){
|
327
|
+
var $t = this;
|
328
|
+
if(!$t.grid) { return; }
|
329
|
+
// Currently we disable a treeGrid drag and drop
|
330
|
+
if($t.p.treeGrid) { return; }
|
331
|
+
if(!$.fn.draggable || !$.fn.droppable) { return; }
|
332
|
+
function updateDnD ()
|
333
|
+
{
|
334
|
+
var datadnd = $.data($t,"dnd");
|
335
|
+
$("tr.jqgrow:not(.ui-draggable)",$t).draggable($.isFunction(datadnd.drag) ? datadnd.drag.call($($t),datadnd) : datadnd.drag);
|
336
|
+
}
|
337
|
+
var appender = "<table id='jqgrid_dnd' class='ui-jqgrid-dnd'></table>";
|
338
|
+
if($("#jqgrid_dnd").html() === null) {
|
339
|
+
$('body').append(appender);
|
340
|
+
}
|
341
|
+
|
342
|
+
if(typeof opts == 'string' && opts == 'updateDnD' && $t.p.jqgdnd===true) {
|
343
|
+
updateDnD();
|
344
|
+
return;
|
345
|
+
}
|
346
|
+
opts = $.extend({
|
347
|
+
"drag" : function (opts) {
|
348
|
+
return $.extend({
|
349
|
+
start : function (ev, ui) {
|
350
|
+
// if we are in subgrid mode try to collapse the node
|
351
|
+
if($t.p.subGrid) {
|
352
|
+
var subgid = $(ui.helper).attr("id");
|
353
|
+
try {
|
354
|
+
$($t).jqGrid('collapseSubGridRow',subgid);
|
355
|
+
} catch (e) {}
|
356
|
+
}
|
357
|
+
// hack
|
358
|
+
// drag and drop does not insert tr in table, when the table has no rows
|
359
|
+
// we try to insert new empty row on the target(s)
|
360
|
+
for (var i=0;i<$.data($t,"dnd").connectWith.length;i++){
|
361
|
+
if($($.data($t,"dnd").connectWith[i]).jqGrid('getGridParam','reccount') == "0" ){
|
362
|
+
$($.data($t,"dnd").connectWith[i]).jqGrid('addRowData','jqg_empty_row',{});
|
363
|
+
}
|
364
|
+
}
|
365
|
+
ui.helper.addClass("ui-state-highlight");
|
366
|
+
$("td",ui.helper).each(function(i) {
|
367
|
+
this.style.width = $t.grid.headers[i].width+"px";
|
368
|
+
});
|
369
|
+
if(opts.onstart && $.isFunction(opts.onstart) ) { opts.onstart.call($($t),ev,ui); }
|
370
|
+
},
|
371
|
+
stop :function(ev,ui) {
|
372
|
+
if(ui.helper.dropped) {
|
373
|
+
var ids = $(ui.helper).attr("id");
|
374
|
+
$($t).jqGrid('delRowData',ids );
|
375
|
+
}
|
376
|
+
// if we have a empty row inserted from start event try to delete it
|
377
|
+
for (var i=0;i<$.data($t,"dnd").connectWith.length;i++){
|
378
|
+
$($.data($t,"dnd").connectWith[i]).jqGrid('delRowData','jqg_empty_row');
|
379
|
+
}
|
380
|
+
if(opts.onstop && $.isFunction(opts.onstop) ) { opts.onstop.call($($t),ev,ui); }
|
381
|
+
}
|
382
|
+
},opts.drag_opts || {});
|
383
|
+
},
|
384
|
+
"drop" : function (opts) {
|
385
|
+
return $.extend({
|
386
|
+
accept: function(d) {
|
387
|
+
var tid = $(d).closest("table.ui-jqgrid-btable");
|
388
|
+
if($.data(tid[0],"dnd") !== undefined) {
|
389
|
+
var cn = $.data(tid[0],"dnd").connectWith;
|
390
|
+
return $.inArray('#'+this.id,cn) != -1 ? true : false;
|
391
|
+
}
|
392
|
+
return d;
|
393
|
+
},
|
394
|
+
drop: function(ev, ui) {
|
395
|
+
var accept = $(ui.draggable).attr("id");
|
396
|
+
var getdata = $('#'+$t.id).jqGrid('getRowData',accept);
|
397
|
+
if(!opts.dropbyname) {
|
398
|
+
var j =0, tmpdata = {}, dropname;
|
399
|
+
var dropmodel = $("#"+this.id).jqGrid('getGridParam','colModel');
|
400
|
+
try {
|
401
|
+
for (var key in getdata) {
|
402
|
+
if(getdata.hasOwnProperty(key) && dropmodel[j]) {
|
403
|
+
dropname = dropmodel[j].name;
|
404
|
+
tmpdata[dropname] = getdata[key];
|
405
|
+
}
|
406
|
+
j++;
|
407
|
+
}
|
408
|
+
getdata = tmpdata;
|
409
|
+
} catch (e) {}
|
410
|
+
}
|
411
|
+
ui.helper.dropped = true;
|
412
|
+
if(opts.beforedrop && $.isFunction(opts.beforedrop) ) {
|
413
|
+
//parameters to this callback - event, element, data to be inserted, sender, reciever
|
414
|
+
// should return object which will be inserted into the reciever
|
415
|
+
var datatoinsert = opts.beforedrop.call(this,ev,ui,getdata,$('#'+$t.id),$(this));
|
416
|
+
if (typeof datatoinsert != "undefined" && datatoinsert !== null && typeof datatoinsert == "object") { getdata = datatoinsert; }
|
417
|
+
}
|
418
|
+
if(ui.helper.dropped) {
|
419
|
+
var grid;
|
420
|
+
if(opts.autoid) {
|
421
|
+
if($.isFunction(opts.autoid)) {
|
422
|
+
grid = opts.autoid.call(this,getdata);
|
423
|
+
} else {
|
424
|
+
grid = Math.ceil(Math.random()*1000);
|
425
|
+
grid = opts.autoidprefix+grid;
|
426
|
+
}
|
427
|
+
}
|
428
|
+
// NULL is interpreted as undefined while null as object
|
429
|
+
$("#"+this.id).jqGrid('addRowData',grid,getdata,opts.droppos);
|
430
|
+
}
|
431
|
+
if(opts.ondrop && $.isFunction(opts.ondrop) ) { opts.ondrop.call(this,ev,ui, getdata); }
|
432
|
+
}}, opts.drop_opts || {});
|
433
|
+
},
|
434
|
+
"onstart" : null,
|
435
|
+
"onstop" : null,
|
436
|
+
"beforedrop": null,
|
437
|
+
"ondrop" : null,
|
438
|
+
"drop_opts" : {
|
439
|
+
"activeClass": "ui-state-active",
|
440
|
+
"hoverClass": "ui-state-hover"
|
441
|
+
},
|
442
|
+
"drag_opts" : {
|
443
|
+
"revert": "invalid",
|
444
|
+
"helper": "clone",
|
445
|
+
"cursor": "move",
|
446
|
+
"appendTo" : "#jqgrid_dnd",
|
447
|
+
"zIndex": 5000
|
448
|
+
},
|
449
|
+
"dropbyname" : false,
|
450
|
+
"droppos" : "first",
|
451
|
+
"autoid" : true,
|
452
|
+
"autoidprefix" : "dnd_"
|
453
|
+
}, opts || {});
|
454
|
+
|
455
|
+
if(!opts.connectWith) { return; }
|
456
|
+
opts.connectWith = opts.connectWith.split(",");
|
457
|
+
opts.connectWith = $.map(opts.connectWith,function(n){return $.trim(n);});
|
458
|
+
$.data($t,"dnd",opts);
|
459
|
+
|
460
|
+
if($t.p.reccount != "0" && !$t.p.jqgdnd) {
|
461
|
+
updateDnD();
|
462
|
+
}
|
463
|
+
$t.p.jqgdnd = true;
|
464
|
+
for (var i=0;i<opts.connectWith.length;i++){
|
465
|
+
var cn =opts.connectWith[i];
|
466
|
+
$(cn).droppable($.isFunction(opts.drop) ? opts.drop.call($($t),opts) : opts.drop);
|
467
|
+
}
|
468
|
+
});
|
469
|
+
},
|
470
|
+
gridResize : function(opts) {
|
471
|
+
return this.each(function(){
|
472
|
+
var $t = this;
|
473
|
+
if(!$t.grid || !$.fn.resizable) { return; }
|
474
|
+
opts = $.extend({}, opts || {});
|
475
|
+
if(opts.alsoResize ) {
|
476
|
+
opts._alsoResize_ = opts.alsoResize;
|
477
|
+
delete opts.alsoResize;
|
478
|
+
} else {
|
479
|
+
opts._alsoResize_ = false;
|
480
|
+
}
|
481
|
+
if(opts.stop && $.isFunction(opts.stop)) {
|
482
|
+
opts._stop_ = opts.stop;
|
483
|
+
delete opts.stop;
|
484
|
+
} else {
|
485
|
+
opts._stop_ = false;
|
486
|
+
}
|
487
|
+
opts.stop = function (ev, ui) {
|
488
|
+
$($t).jqGrid('setGridParam',{height:$("#gview_"+$t.p.id+" .ui-jqgrid-bdiv").height()});
|
489
|
+
$($t).jqGrid('setGridWidth',ui.size.width,opts.shrinkToFit);
|
490
|
+
if(opts._stop_) { opts._stop_.call($t,ev,ui); }
|
491
|
+
};
|
492
|
+
if(opts._alsoResize_) {
|
493
|
+
var optstest = "{\'#gview_"+$t.p.id+" .ui-jqgrid-bdiv\':true,'" +opts._alsoResize_+"':true}";
|
494
|
+
opts.alsoResize = eval('('+optstest+')'); // the only way that I found to do this
|
495
|
+
} else {
|
496
|
+
opts.alsoResize = $(".ui-jqgrid-bdiv","#gview_"+$t.p.id);
|
497
|
+
}
|
498
|
+
delete opts._alsoResize_;
|
499
|
+
$("#gbox_"+$t.p.id).resizable(opts);
|
500
|
+
});
|
501
|
+
}
|
502
|
+
});
|
503
|
+
})(jQuery);
|
@@ -0,0 +1,47 @@
|
|
1
|
+
// This file should be used if you want to debug
|
2
|
+
function jqGridInclude()
|
3
|
+
{
|
4
|
+
var pathtojsfiles = "js/"; // need to be ajusted
|
5
|
+
// set include to false if you do not want some modules to be included
|
6
|
+
var modules = [
|
7
|
+
{ include: true, incfile:'i18n/grid.locale-en.js'}, // jqGrid translation
|
8
|
+
{ include: true, incfile:'grid.base.js'}, // jqGrid base
|
9
|
+
{ include: true, incfile:'grid.common.js'}, // jqGrid common for editing
|
10
|
+
{ include: true, incfile:'grid.formedit.js'}, // jqGrid Form editing
|
11
|
+
{ include: true, incfile:'grid.inlinedit.js'}, // jqGrid inline editing
|
12
|
+
{ include: true, incfile:'grid.celledit.js'}, // jqGrid cell editing
|
13
|
+
{ include: true, incfile:'grid.subgrid.js'}, //jqGrid subgrid
|
14
|
+
{ include: true, incfile:'grid.treegrid.js'}, //jqGrid treegrid
|
15
|
+
{ include: true, incfile:'grid.custom.js'}, //jqGrid custom
|
16
|
+
{ include: true, incfile:'grid.postext.js'}, //jqGrid postext
|
17
|
+
{ include: true, incfile:'grid.tbltogrid.js'}, //jqGrid table to grid
|
18
|
+
{ include: true, incfile:'grid.setcolumns.js'}, //jqGrid setcolumns
|
19
|
+
{ include: true, incfile:'grid.import.js'}, //jqGrid import
|
20
|
+
{ include: true, incfile:'jquery.fmatter.js'}, //jqGrid formater
|
21
|
+
{ include: true, incfile:'JsonXml.js'}, //xmljson utils
|
22
|
+
{ include: true, incfile:'jquery.searchFilter.js'} // search Plugin
|
23
|
+
];
|
24
|
+
var filename;
|
25
|
+
for(var i=0;i<modules.length; i++)
|
26
|
+
{
|
27
|
+
if(modules[i].include === true) {
|
28
|
+
|
29
|
+
filename = pathtojsfiles+modules[i].incfile;
|
30
|
+
if(jQuery.browser.safari) {
|
31
|
+
jQuery.ajax({url:filename,dataType:'script', async:false, cache: true});
|
32
|
+
} else {
|
33
|
+
IncludeJavaScript(filename);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
function IncludeJavaScript(jsFile)
|
38
|
+
{
|
39
|
+
var oHead = document.getElementsByTagName('head')[0];
|
40
|
+
var oScript = document.createElement('script');
|
41
|
+
oScript.type = 'text/javascript';
|
42
|
+
oScript.charset = 'utf-8';
|
43
|
+
oScript.src = jsFile;
|
44
|
+
oHead.appendChild(oScript);
|
45
|
+
};
|
46
|
+
};
|
47
|
+
jqGridInclude();
|
@@ -0,0 +1,64 @@
|
|
1
|
+
;(function($){
|
2
|
+
/**
|
3
|
+
* jqGrid extension
|
4
|
+
* Paul Tiseo ptiseo@wasteconsultants.com
|
5
|
+
*
|
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
|
+
getPostData : function(){
|
12
|
+
var $t = this[0];
|
13
|
+
if(!$t.grid) { return; }
|
14
|
+
return $t.p.postData;
|
15
|
+
},
|
16
|
+
setPostData : function( newdata ) {
|
17
|
+
var $t = this[0];
|
18
|
+
if(!$t.grid) { return; }
|
19
|
+
// check if newdata is correct type
|
20
|
+
if ( typeof(newdata) === 'object' ) {
|
21
|
+
$t.p.postData = newdata;
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
alert("Error: cannot add a non-object postData value. postData unchanged.");
|
25
|
+
}
|
26
|
+
},
|
27
|
+
appendPostData : function( newdata ) {
|
28
|
+
var $t = this[0];
|
29
|
+
if(!$t.grid) { return; }
|
30
|
+
// check if newdata is correct type
|
31
|
+
if ( typeof(newdata) === 'object' ) {
|
32
|
+
$.extend($t.p.postData, newdata);
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
alert("Error: cannot append a non-object postData value. postData unchanged.");
|
36
|
+
}
|
37
|
+
},
|
38
|
+
setPostDataItem : function( key, val ) {
|
39
|
+
var $t = this[0];
|
40
|
+
if(!$t.grid) { return; }
|
41
|
+
$t.p.postData[key] = val;
|
42
|
+
},
|
43
|
+
getPostDataItem : function( key ) {
|
44
|
+
var $t = this[0];
|
45
|
+
if(!$t.grid) { return; }
|
46
|
+
return $t.p.postData[key];
|
47
|
+
},
|
48
|
+
removePostDataItem : function( key ) {
|
49
|
+
var $t = this[0];
|
50
|
+
if(!$t.grid) { return; }
|
51
|
+
delete $t.p.postData[key];
|
52
|
+
},
|
53
|
+
getUserData : function(){
|
54
|
+
var $t = this[0];
|
55
|
+
if(!$t.grid) { return; }
|
56
|
+
return $t.p.userData;
|
57
|
+
},
|
58
|
+
getUserDataItem : function( key ) {
|
59
|
+
var $t = this[0];
|
60
|
+
if(!$t.grid) { return; }
|
61
|
+
return $t.p.userData[key];
|
62
|
+
}
|
63
|
+
});
|
64
|
+
})(jQuery);
|