rails_jq_grid 0.0.3.pre2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/public/javascripts/rails-jqgrid/Changes.txt +0 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg.js +132 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-bg1251.js +132 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cat.js +128 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cn.js +132 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-cs.js +128 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-da.js +128 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-de.js +133 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-el.js +126 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-en.js +128 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-es.js +128 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fa.js +145 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fi.js +130 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-fr.js +126 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-gl.js +126 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-he.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-hu.js +129 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-is.js +126 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-it.js +1 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ja.js +155 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-nl.js +149 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-no.js +1 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pl.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt-br.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-pt.js +125 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ro.js +139 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ru.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-sk.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-sr.js +128 -0
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-sv.js +127 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-tr.js +126 -1
- data/public/javascripts/rails-jqgrid/i18n/grid.locale-ua.js +127 -1
- data/public/javascripts/rails-jqgrid/install.txt +0 -0
- data/public/javascripts/rails-jqgrid/jquery.jqGrid.min.js +445 -432
- data/public/javascripts/rails-jqgrid/src/JsonXml.js +329 -329
- data/public/javascripts/rails-jqgrid/src/css/ellipsis-xbl.xml +0 -0
- data/public/javascripts/rails-jqgrid/src/css/ui.jqgrid.css +139 -129
- data/public/javascripts/rails-jqgrid/src/css/ui.multiselect.css +0 -0
- data/public/javascripts/rails-jqgrid/src/grid.base.js +3078 -3003
- data/public/javascripts/rails-jqgrid/src/grid.celledit.js +486 -486
- data/public/javascripts/rails-jqgrid/src/grid.common.js +646 -636
- data/public/javascripts/rails-jqgrid/src/grid.custom.js +820 -817
- data/public/javascripts/rails-jqgrid/src/grid.formedit.js +1954 -1872
- data/public/javascripts/rails-jqgrid/src/grid.grouping.js +250 -0
- data/public/javascripts/rails-jqgrid/src/grid.import.js +200 -200
- data/public/javascripts/rails-jqgrid/src/grid.inlinedit.js +255 -250
- data/public/javascripts/rails-jqgrid/src/grid.jqueryui.js +504 -503
- data/public/javascripts/rails-jqgrid/src/grid.loader.js +1 -0
- data/public/javascripts/rails-jqgrid/src/grid.postext.js +63 -63
- data/public/javascripts/rails-jqgrid/src/grid.setcolumns.js +125 -125
- data/public/javascripts/rails-jqgrid/src/grid.subgrid.js +260 -260
- data/public/javascripts/rails-jqgrid/src/grid.tbltogrid.js +106 -106
- data/public/javascripts/rails-jqgrid/src/grid.treegrid.js +489 -482
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg.js +132 -132
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-bg1251.js +132 -132
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cat.js +128 -128
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cn.js +132 -132
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-cs.js +128 -128
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-da.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-de.js +132 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-dk.js +0 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-el.js +126 -126
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-en.js +128 -128
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-es.js +128 -128
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fa.js +145 -125
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fi.js +130 -130
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-fr.js +2 -2
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-gl.js +126 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-he.js +127 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-hu.js +129 -129
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-is.js +126 -126
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-it.js +0 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ja.js +155 -155
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-nl.js +148 -148
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-no.js +0 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pl.js +126 -126
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt-br.js +127 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-pt.js +125 -125
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ro.js +139 -139
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ru.js +127 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sk.js +127 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sr.js +128 -0
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-sv.js +127 -127
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-tr.js +126 -126
- data/public/javascripts/rails-jqgrid/src/i18n/grid.locale-ua.js +127 -127
- data/public/javascripts/rails-jqgrid/src/jqDnR.js +68 -67
- data/public/javascripts/rails-jqgrid/src/jqModal.js +68 -68
- data/public/javascripts/rails-jqgrid/src/jquery.fmatter.js +563 -541
- data/public/javascripts/rails-jqgrid/src/jquery.searchFilter.js +1 -1
- data/public/javascripts/rails-jqgrid/src/ui.multiselect.js +0 -0
- data/public/stylesheets/rails-jqgrid/ellipsis-xbl.xml +0 -0
- data/public/stylesheets/rails-jqgrid/ui.jqgrid.css +139 -2
- data/rails_jq_grid.gemspec +10 -3
- metadata +15 -11
@@ -1,106 +1,106 @@
|
|
1
|
-
/*
|
2
|
-
Transform a table to a jqGrid.
|
3
|
-
Peter Romianowski <peter.romianowski@optivo.de>
|
4
|
-
If the first column of the table contains checkboxes or
|
5
|
-
radiobuttons then the jqGrid is made selectable.
|
6
|
-
*/
|
7
|
-
// Addition - selector can be a class or id
|
8
|
-
function tableToGrid(selector, options) {
|
9
|
-
jQuery(selector).each(function() {
|
10
|
-
if(this.grid) {return;} //Adedd from Tony Tomov
|
11
|
-
// This is a small "hack" to make the width of the jqGrid 100%
|
12
|
-
jQuery(this).width("99%");
|
13
|
-
var w = jQuery(this).width();
|
14
|
-
|
15
|
-
// Text whether we have single or multi select
|
16
|
-
var inputCheckbox = jQuery('input[type=checkbox]:first', jQuery(this));
|
17
|
-
var inputRadio = jQuery('input[type=radio]:first', jQuery(this));
|
18
|
-
var selectMultiple = inputCheckbox.length > 0;
|
19
|
-
var selectSingle = !selectMultiple && inputRadio.length > 0;
|
20
|
-
var selectable = selectMultiple || selectSingle;
|
21
|
-
var inputName = inputCheckbox.attr("name") || inputRadio.attr("name");
|
22
|
-
|
23
|
-
// Build up the columnModel and the data
|
24
|
-
var colModel = [];
|
25
|
-
var colNames = [];
|
26
|
-
jQuery('th', jQuery(this)).each(function() {
|
27
|
-
if (colModel.length === 0 && selectable) {
|
28
|
-
colModel.push({
|
29
|
-
name: '__selection__',
|
30
|
-
index: '__selection__',
|
31
|
-
width: 0,
|
32
|
-
hidden: true
|
33
|
-
});
|
34
|
-
colNames.push('__selection__');
|
35
|
-
} else {
|
36
|
-
colModel.push({
|
37
|
-
name: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(' ').join('_'),
|
38
|
-
index: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(' ').join('_'),
|
39
|
-
width: jQuery(this).width() || 150
|
40
|
-
});
|
41
|
-
colNames.push(jQuery(this).html());
|
42
|
-
}
|
43
|
-
});
|
44
|
-
var data = [];
|
45
|
-
var rowIds = [];
|
46
|
-
var rowChecked = [];
|
47
|
-
jQuery('tbody > tr', jQuery(this)).each(function() {
|
48
|
-
var row = {};
|
49
|
-
var rowPos = 0;
|
50
|
-
jQuery('td', jQuery(this)).each(function() {
|
51
|
-
if (rowPos === 0 && selectable) {
|
52
|
-
var input = jQuery('input', jQuery(this));
|
53
|
-
var rowId = input.attr("value");
|
54
|
-
rowIds.push(rowId || data.length);
|
55
|
-
if (input.attr("checked")) {
|
56
|
-
rowChecked.push(rowId);
|
57
|
-
}
|
58
|
-
row[colModel[rowPos].name] = input.attr("value");
|
59
|
-
} else {
|
60
|
-
row[colModel[rowPos].name] = jQuery(this).html();
|
61
|
-
}
|
62
|
-
rowPos++;
|
63
|
-
});
|
64
|
-
if(rowPos >0) { data.push(row); }
|
65
|
-
});
|
66
|
-
|
67
|
-
// Clear the original HTML table
|
68
|
-
jQuery(this).empty();
|
69
|
-
|
70
|
-
// Mark it as jqGrid
|
71
|
-
jQuery(this).addClass("scroll");
|
72
|
-
|
73
|
-
jQuery(this).jqGrid(jQuery.extend({
|
74
|
-
datatype: "local",
|
75
|
-
width: w,
|
76
|
-
colNames: colNames,
|
77
|
-
colModel: colModel,
|
78
|
-
multiselect: selectMultiple
|
79
|
-
//inputName: inputName,
|
80
|
-
//inputValueCol: imputName != null ? "__selection__" : null
|
81
|
-
}, options || {}));
|
82
|
-
|
83
|
-
// Add data
|
84
|
-
var a;
|
85
|
-
for (a = 0; a < data.length; a++) {
|
86
|
-
var id = null;
|
87
|
-
if (rowIds.length > 0) {
|
88
|
-
id = rowIds[a];
|
89
|
-
if (id && id.replace) {
|
90
|
-
// We have to do this since the value of a checkbox
|
91
|
-
// or radio button can be anything
|
92
|
-
id = encodeURIComponent(id).replace(/[.\-%]/g, "_");
|
93
|
-
}
|
94
|
-
}
|
95
|
-
if (id === null) {
|
96
|
-
id = a + 1;
|
97
|
-
}
|
98
|
-
jQuery(this).jqGrid("addRowData",id, data[a]);
|
99
|
-
}
|
100
|
-
|
101
|
-
// Set the selection
|
102
|
-
for (a = 0; a < rowChecked.length; a++) {
|
103
|
-
jQuery(this).jqGrid("setSelection",rowChecked[a]);
|
104
|
-
}
|
105
|
-
});
|
106
|
-
};
|
1
|
+
/*
|
2
|
+
Transform a table to a jqGrid.
|
3
|
+
Peter Romianowski <peter.romianowski@optivo.de>
|
4
|
+
If the first column of the table contains checkboxes or
|
5
|
+
radiobuttons then the jqGrid is made selectable.
|
6
|
+
*/
|
7
|
+
// Addition - selector can be a class or id
|
8
|
+
function tableToGrid(selector, options) {
|
9
|
+
jQuery(selector).each(function() {
|
10
|
+
if(this.grid) {return;} //Adedd from Tony Tomov
|
11
|
+
// This is a small "hack" to make the width of the jqGrid 100%
|
12
|
+
jQuery(this).width("99%");
|
13
|
+
var w = jQuery(this).width();
|
14
|
+
|
15
|
+
// Text whether we have single or multi select
|
16
|
+
var inputCheckbox = jQuery('input[type=checkbox]:first', jQuery(this));
|
17
|
+
var inputRadio = jQuery('input[type=radio]:first', jQuery(this));
|
18
|
+
var selectMultiple = inputCheckbox.length > 0;
|
19
|
+
var selectSingle = !selectMultiple && inputRadio.length > 0;
|
20
|
+
var selectable = selectMultiple || selectSingle;
|
21
|
+
//var inputName = inputCheckbox.attr("name") || inputRadio.attr("name");
|
22
|
+
|
23
|
+
// Build up the columnModel and the data
|
24
|
+
var colModel = [];
|
25
|
+
var colNames = [];
|
26
|
+
jQuery('th', jQuery(this)).each(function() {
|
27
|
+
if (colModel.length === 0 && selectable) {
|
28
|
+
colModel.push({
|
29
|
+
name: '__selection__',
|
30
|
+
index: '__selection__',
|
31
|
+
width: 0,
|
32
|
+
hidden: true
|
33
|
+
});
|
34
|
+
colNames.push('__selection__');
|
35
|
+
} else {
|
36
|
+
colModel.push({
|
37
|
+
name: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(' ').join('_'),
|
38
|
+
index: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(' ').join('_'),
|
39
|
+
width: jQuery(this).width() || 150
|
40
|
+
});
|
41
|
+
colNames.push(jQuery(this).html());
|
42
|
+
}
|
43
|
+
});
|
44
|
+
var data = [];
|
45
|
+
var rowIds = [];
|
46
|
+
var rowChecked = [];
|
47
|
+
jQuery('tbody > tr', jQuery(this)).each(function() {
|
48
|
+
var row = {};
|
49
|
+
var rowPos = 0;
|
50
|
+
jQuery('td', jQuery(this)).each(function() {
|
51
|
+
if (rowPos === 0 && selectable) {
|
52
|
+
var input = jQuery('input', jQuery(this));
|
53
|
+
var rowId = input.attr("value");
|
54
|
+
rowIds.push(rowId || data.length);
|
55
|
+
if (input.attr("checked")) {
|
56
|
+
rowChecked.push(rowId);
|
57
|
+
}
|
58
|
+
row[colModel[rowPos].name] = input.attr("value");
|
59
|
+
} else {
|
60
|
+
row[colModel[rowPos].name] = jQuery(this).html();
|
61
|
+
}
|
62
|
+
rowPos++;
|
63
|
+
});
|
64
|
+
if(rowPos >0) { data.push(row); }
|
65
|
+
});
|
66
|
+
|
67
|
+
// Clear the original HTML table
|
68
|
+
jQuery(this).empty();
|
69
|
+
|
70
|
+
// Mark it as jqGrid
|
71
|
+
jQuery(this).addClass("scroll");
|
72
|
+
|
73
|
+
jQuery(this).jqGrid(jQuery.extend({
|
74
|
+
datatype: "local",
|
75
|
+
width: w,
|
76
|
+
colNames: colNames,
|
77
|
+
colModel: colModel,
|
78
|
+
multiselect: selectMultiple
|
79
|
+
//inputName: inputName,
|
80
|
+
//inputValueCol: imputName != null ? "__selection__" : null
|
81
|
+
}, options || {}));
|
82
|
+
|
83
|
+
// Add data
|
84
|
+
var a;
|
85
|
+
for (a = 0; a < data.length; a++) {
|
86
|
+
var id = null;
|
87
|
+
if (rowIds.length > 0) {
|
88
|
+
id = rowIds[a];
|
89
|
+
if (id && id.replace) {
|
90
|
+
// We have to do this since the value of a checkbox
|
91
|
+
// or radio button can be anything
|
92
|
+
id = encodeURIComponent(id).replace(/[.\-%]/g, "_");
|
93
|
+
}
|
94
|
+
}
|
95
|
+
if (id === null) {
|
96
|
+
id = a + 1;
|
97
|
+
}
|
98
|
+
jQuery(this).jqGrid("addRowData",id, data[a]);
|
99
|
+
}
|
100
|
+
|
101
|
+
// Set the selection
|
102
|
+
for (a = 0; a < rowChecked.length; a++) {
|
103
|
+
jQuery(this).jqGrid("setSelection",rowChecked[a]);
|
104
|
+
}
|
105
|
+
});
|
106
|
+
};
|
@@ -1,483 +1,490 @@
|
|
1
|
-
;(function($) {
|
2
|
-
/*
|
3
|
-
**
|
4
|
-
* jqGrid extension - Tree Grid
|
5
|
-
* Tony Tomov tony@trirand.com
|
6
|
-
* http://trirand.com/blog/
|
7
|
-
* Dual licensed under the MIT and GPL licenses:
|
8
|
-
* http://www.opensource.org/licenses/mit-license.php
|
9
|
-
* http://www.gnu.org/licenses/gpl.html
|
10
|
-
**/
|
11
|
-
$.jgrid.extend({
|
12
|
-
setTreeNode : function(rd, row){
|
13
|
-
return this.each(function(){
|
14
|
-
var $t = this;
|
15
|
-
if( !$t.grid || !$t.p.treeGrid ) { return; }
|
16
|
-
var expCol = $t.p.expColInd
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
rd[
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
rd[
|
56
|
-
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
}
|
128
|
-
|
129
|
-
$t.p.treeReader = $.extend({
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
$t.p.colModel.
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
$
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
$
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
$
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
}
|
318
|
-
});
|
319
|
-
break;
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
}
|
348
|
-
});
|
349
|
-
return
|
350
|
-
},
|
351
|
-
|
352
|
-
var result;
|
353
|
-
this.each(function(){
|
354
|
-
var $t = this;
|
355
|
-
if(!$t.grid || !$t.p.treeGrid) { return; }
|
356
|
-
var
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
result
|
361
|
-
}
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
if(
|
370
|
-
var
|
371
|
-
if(
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
}
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
1
|
+
;(function($) {
|
2
|
+
/*
|
3
|
+
**
|
4
|
+
* jqGrid extension - Tree Grid
|
5
|
+
* Tony Tomov tony@trirand.com
|
6
|
+
* http://trirand.com/blog/
|
7
|
+
* Dual licensed under the MIT and GPL licenses:
|
8
|
+
* http://www.opensource.org/licenses/mit-license.php
|
9
|
+
* http://www.gnu.org/licenses/gpl.html
|
10
|
+
**/
|
11
|
+
$.jgrid.extend({
|
12
|
+
setTreeNode : function(rd, row){
|
13
|
+
return this.each(function(){
|
14
|
+
var $t = this;
|
15
|
+
if( !$t.grid || !$t.p.treeGrid ) { return; }
|
16
|
+
var expCol = $t.p.expColInd,
|
17
|
+
expanded = $t.p.treeReader.expanded_field,
|
18
|
+
isLeaf = $t.p.treeReader.leaf_field,
|
19
|
+
level = $t.p.treeReader.level_field,
|
20
|
+
loaded = $t.p.treeReader.loaded;
|
21
|
+
|
22
|
+
row.level = rd[level];
|
23
|
+
|
24
|
+
if($t.p.treeGridModel == 'nested') {
|
25
|
+
var lft = rd[$t.p.treeReader.left_field],
|
26
|
+
rgt = rd[$t.p.treeReader.right_field];
|
27
|
+
if(!rd[isLeaf]) {
|
28
|
+
// NS Model
|
29
|
+
rd[isLeaf] = (parseInt(rgt,10) === parseInt(lft,10)+1) ? 'true' : 'false';
|
30
|
+
}
|
31
|
+
} else {
|
32
|
+
//row.parent_id = rd[$t.p.treeReader.parent_id_field];
|
33
|
+
}
|
34
|
+
var curLevel = parseInt(rd[level],10), ident,lftpos;
|
35
|
+
if($t.p.tree_root_level === 0) {
|
36
|
+
ident = curLevel+1;
|
37
|
+
lftpos = curLevel;
|
38
|
+
} else {
|
39
|
+
ident = curLevel;
|
40
|
+
lftpos = curLevel -1;
|
41
|
+
}
|
42
|
+
var twrap = "<div class='tree-wrap tree-wrap-"+$t.p.direction+"' style='width:"+(ident*18)+"px;'>";
|
43
|
+
twrap += "<div style='"+($t.p.direction=="rtl" ? "right:" : "left:")+(lftpos*18)+"px;' class='ui-icon ";
|
44
|
+
|
45
|
+
if(rd[loaded] != undefined) {
|
46
|
+
if(rd[loaded]=="true" || rd[loaded]===true) {
|
47
|
+
rd[loaded] = true;
|
48
|
+
} else {
|
49
|
+
rd[loaded] = false;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
if(rd[isLeaf] == "true" || rd[isLeaf] === true) {
|
53
|
+
twrap += $t.p.treeIcons.leaf+" tree-leaf'";
|
54
|
+
rd[isLeaf] = true;
|
55
|
+
rd[expanded] = false;
|
56
|
+
} else {
|
57
|
+
if(rd[expanded] == "true" || rd[expanded] === true) {
|
58
|
+
twrap += $t.p.treeIcons.minus+" tree-minus treeclick'";
|
59
|
+
rd[expanded] = true;
|
60
|
+
} else {
|
61
|
+
twrap += $t.p.treeIcons.plus+" tree-plus treeclick'";
|
62
|
+
rd[expanded] = false;
|
63
|
+
}
|
64
|
+
rd[isLeaf] = false;
|
65
|
+
}
|
66
|
+
twrap += "</div></div>";
|
67
|
+
if(!$t.p.loadonce) {
|
68
|
+
rd[$t.p.localReader.id] = row.id;
|
69
|
+
$t.p.data.push(rd);
|
70
|
+
$t.p._index[row.id]=$t.p.data.length-1;
|
71
|
+
}
|
72
|
+
if(parseInt(rd[level],10) !== parseInt($t.p.tree_root_level,10)) {
|
73
|
+
if(!$($t).jqGrid("isVisibleNode",rd)){
|
74
|
+
$(row).css("display","none");
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
$("td:eq("+expCol+")",row).wrapInner("<span></span>").prepend(twrap);
|
79
|
+
$(".treeclick",row).bind("click",function(e){
|
80
|
+
var target = e.target || e.srcElement,
|
81
|
+
ind2 =$(target,$t.rows).closest("tr.jqgrow")[0].id,
|
82
|
+
pos = $t.p._index[ind2],
|
83
|
+
isLeaf = $t.p.treeReader.leaf_field,
|
84
|
+
expanded = $t.p.treeReader.expanded_field;
|
85
|
+
if(!$t.p.data[pos][isLeaf]){
|
86
|
+
if($t.p.data[pos][expanded]){
|
87
|
+
$($t).jqGrid("collapseRow",$t.p.data[pos]);
|
88
|
+
$($t).jqGrid("collapseNode",$t.p.data[pos]);
|
89
|
+
} else {
|
90
|
+
$($t).jqGrid("expandRow",$t.p.data[pos]);
|
91
|
+
$($t).jqGrid("expandNode",$t.p.data[pos]);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return false;
|
95
|
+
});
|
96
|
+
if($t.p.ExpandColClick === true) {
|
97
|
+
$("span", row).css("cursor","pointer").bind("click",function(e){
|
98
|
+
var target = e.target || e.srcElement,
|
99
|
+
ind2 =$(target,$t.rows).closest("tr.jqgrow")[0].id,
|
100
|
+
pos = $t.p._index[ind2],
|
101
|
+
isLeaf = $t.p.treeReader.leaf_field,
|
102
|
+
expanded = $t.p.treeReader.expanded_field;
|
103
|
+
if(!$t.p.data[pos][isLeaf]){
|
104
|
+
if($t.p.data[pos][expanded]){
|
105
|
+
$($t).jqGrid("collapseRow",$t.p.data[pos]);
|
106
|
+
$($t).jqGrid("collapseNode",$t.p.data[pos]);
|
107
|
+
} else {
|
108
|
+
$($t).jqGrid("expandRow",$t.p.data[pos]);
|
109
|
+
$($t).jqGrid("expandNode",$t.p.data[pos]);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
$($t).jqGrid("setSelection",ind2);
|
113
|
+
return false;
|
114
|
+
});
|
115
|
+
}
|
116
|
+
});
|
117
|
+
},
|
118
|
+
setTreeGrid : function() {
|
119
|
+
return this.each(function (){
|
120
|
+
var $t = this, i=0, pico;
|
121
|
+
if(!$t.p.treeGrid) { return; }
|
122
|
+
if(!$t.p.treedatatype ) { $.extend($t.p,{treedatatype: $t.p.datatype}); }
|
123
|
+
$t.p.subGrid = false; $t.p.altRows =false;
|
124
|
+
$t.p.pgbuttons = false; $t.p.pginput = false;
|
125
|
+
$t.p.multiselect = false; $t.p.rowList = [];
|
126
|
+
pico = 'ui-icon-triangle-1-' + ($t.p.direction=="rtl" ? 'w' : 'e');
|
127
|
+
$t.p.treeIcons = $.extend({plus:pico,minus:'ui-icon-triangle-1-s',leaf:'ui-icon-radio-off'},$t.p.treeIcons || {});
|
128
|
+
if($t.p.treeGridModel == 'nested') {
|
129
|
+
$t.p.treeReader = $.extend({
|
130
|
+
level_field: "level",
|
131
|
+
left_field:"lft",
|
132
|
+
right_field: "rgt",
|
133
|
+
leaf_field: "isLeaf",
|
134
|
+
expanded_field: "expanded",
|
135
|
+
loaded: "loaded"
|
136
|
+
},$t.p.treeReader);
|
137
|
+
} else
|
138
|
+
if($t.p.treeGridModel == 'adjacency') {
|
139
|
+
$t.p.treeReader = $.extend({
|
140
|
+
level_field: "level",
|
141
|
+
parent_id_field: "parent",
|
142
|
+
leaf_field: "isLeaf",
|
143
|
+
expanded_field: "expanded",
|
144
|
+
loaded: "loaded"
|
145
|
+
},$t.p.treeReader );
|
146
|
+
}
|
147
|
+
for (var key in $t.p.colModel){
|
148
|
+
if($t.p.colModel.hasOwnProperty(key)) {
|
149
|
+
if($t.p.colModel[key].name == $t.p.ExpandColumn) {
|
150
|
+
$t.p.expColInd = i;
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
i++;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
if(!$t.p.expColInd) { $t.p.expColInd = 0; }
|
157
|
+
$.each($t.p.treeReader,function(i,n){
|
158
|
+
if(n){
|
159
|
+
$t.p.colNames.push(n);
|
160
|
+
$t.p.colModel.push({name:n,width:1,hidden:true,sortable:false,resizable:false,hidedlg:true,editable:true,search:false});
|
161
|
+
}
|
162
|
+
});
|
163
|
+
});
|
164
|
+
},
|
165
|
+
expandRow: function (record){
|
166
|
+
this.each(function(){
|
167
|
+
var $t = this;
|
168
|
+
if(!$t.grid || !$t.p.treeGrid) { return; }
|
169
|
+
var childern = $($t).jqGrid("getNodeChildren",record),
|
170
|
+
//if ($($t).jqGrid("isVisibleNode",record)) {
|
171
|
+
expanded = $t.p.treeReader.expanded_field;
|
172
|
+
$(childern).each(function(i){
|
173
|
+
var id = $.jgrid.getAccessor(this,$t.p.localReader.id);
|
174
|
+
$("#"+id,$t.grid.bDiv).css("display","");
|
175
|
+
if(this[expanded]) {
|
176
|
+
$($t).jqGrid("expandRow",this);
|
177
|
+
}
|
178
|
+
});
|
179
|
+
//}
|
180
|
+
});
|
181
|
+
},
|
182
|
+
collapseRow : function (record) {
|
183
|
+
this.each(function(){
|
184
|
+
var $t = this;
|
185
|
+
if(!$t.grid || !$t.p.treeGrid) { return; }
|
186
|
+
var childern = $($t).jqGrid("getNodeChildren",record),
|
187
|
+
expanded = $t.p.treeReader.expanded_field;
|
188
|
+
$(childern).each(function(i){
|
189
|
+
var id = $.jgrid.getAccessor(this,$t.p.localReader.id);
|
190
|
+
$("#"+id,$t.grid.bDiv).css("display","none");
|
191
|
+
if(this[expanded]){
|
192
|
+
$($t).jqGrid("collapseRow",this);
|
193
|
+
}
|
194
|
+
});
|
195
|
+
});
|
196
|
+
},
|
197
|
+
// NS ,adjacency models
|
198
|
+
getRootNodes : function() {
|
199
|
+
var result = [];
|
200
|
+
this.each(function(){
|
201
|
+
var $t = this;
|
202
|
+
if(!$t.grid || !$t.p.treeGrid) { return; }
|
203
|
+
switch ($t.p.treeGridModel) {
|
204
|
+
case 'nested' :
|
205
|
+
var level = $t.p.treeReader.level_field;
|
206
|
+
$($t.p.data).each(function(i){
|
207
|
+
if(parseInt(this[level],10) === parseInt($t.p.tree_root_level,10)) {
|
208
|
+
result.push(this);
|
209
|
+
}
|
210
|
+
});
|
211
|
+
break;
|
212
|
+
case 'adjacency' :
|
213
|
+
var parent_id = $t.p.treeReader.parent_id_field;
|
214
|
+
$($t.p.data).each(function(i){
|
215
|
+
if(this[parent_id] === null || String(this[parent_id]).toLowerCase() == "null") {
|
216
|
+
result.push(this);
|
217
|
+
}
|
218
|
+
});
|
219
|
+
break;
|
220
|
+
}
|
221
|
+
});
|
222
|
+
return result;
|
223
|
+
},
|
224
|
+
getNodeDepth : function(rc) {
|
225
|
+
var ret = null;
|
226
|
+
this.each(function(){
|
227
|
+
if(!this.grid || !this.p.treeGrid) { return; }
|
228
|
+
var $t = this;
|
229
|
+
switch ($t.p.treeGridModel) {
|
230
|
+
case 'nested' :
|
231
|
+
var level = $t.p.treeReader.level_field;
|
232
|
+
ret = parseInt(rc[level],10) - parseInt($t.p.tree_root_level,10);
|
233
|
+
break;
|
234
|
+
case 'adjacency' :
|
235
|
+
ret = $($t).jqGrid("getNodeAncestors",rc).length;
|
236
|
+
break;
|
237
|
+
}
|
238
|
+
});
|
239
|
+
return ret;
|
240
|
+
},
|
241
|
+
getNodeParent : function(rc) {
|
242
|
+
var result = null;
|
243
|
+
this.each(function(){
|
244
|
+
var $t = this;
|
245
|
+
if(!$t.grid || !$t.p.treeGrid) { return; }
|
246
|
+
switch ($t.p.treeGridModel) {
|
247
|
+
case 'nested' :
|
248
|
+
var lftc = $t.p.treeReader.left_field,
|
249
|
+
rgtc = $t.p.treeReader.right_field,
|
250
|
+
levelc = $t.p.treeReader.level_field,
|
251
|
+
lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
|
252
|
+
$(this.p.data).each(function(){
|
253
|
+
if(parseInt(this[levelc],10) === level-1 && parseInt(this[lftc],10) < lft && parseInt(this[rgtc],10) > rgt) {
|
254
|
+
result = this;
|
255
|
+
return false;
|
256
|
+
}
|
257
|
+
});
|
258
|
+
break;
|
259
|
+
case 'adjacency' :
|
260
|
+
var parent_id = $t.p.treeReader.parent_id_field,
|
261
|
+
dtid = $t.p.localReader.id;
|
262
|
+
$(this.p.data).each(function(i,val){
|
263
|
+
if(this[dtid] == rc[parent_id] ) {
|
264
|
+
result = this;
|
265
|
+
return false;
|
266
|
+
}
|
267
|
+
});
|
268
|
+
break;
|
269
|
+
}
|
270
|
+
});
|
271
|
+
return result;
|
272
|
+
},
|
273
|
+
getNodeChildren : function(rc) {
|
274
|
+
var result = [];
|
275
|
+
this.each(function(){
|
276
|
+
var $t = this;
|
277
|
+
if(!$t.grid || !$t.p.treeGrid) { return; }
|
278
|
+
switch ($t.p.treeGridModel) {
|
279
|
+
case 'nested' :
|
280
|
+
var lftc = $t.p.treeReader.left_field,
|
281
|
+
rgtc = $t.p.treeReader.right_field,
|
282
|
+
levelc = $t.p.treeReader.level_field,
|
283
|
+
lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
|
284
|
+
$(this.p.data).each(function(i){
|
285
|
+
if(parseInt(this[levelc],10) === level+1 && parseInt(this[lftc],10) > lft && parseInt(this[rgtc],10) < rgt) {
|
286
|
+
result.push(this);
|
287
|
+
}
|
288
|
+
});
|
289
|
+
break;
|
290
|
+
case 'adjacency' :
|
291
|
+
var parent_id = $t.p.treeReader.parent_id_field,
|
292
|
+
dtid = $t.p.localReader.id;
|
293
|
+
$(this.p.data).each(function(i,val){
|
294
|
+
if(this[parent_id] == rc[dtid]) {
|
295
|
+
result.push(this);
|
296
|
+
}
|
297
|
+
});
|
298
|
+
break;
|
299
|
+
}
|
300
|
+
});
|
301
|
+
return result;
|
302
|
+
},
|
303
|
+
getFullTreeNode : function(rc) {
|
304
|
+
var result = [];
|
305
|
+
this.each(function(){
|
306
|
+
var $t = this, len;
|
307
|
+
if(!$t.grid || !$t.p.treeGrid) { return; }
|
308
|
+
switch ($t.p.treeGridModel) {
|
309
|
+
case 'nested' :
|
310
|
+
var lftc = $t.p.treeReader.left_field,
|
311
|
+
rgtc = $t.p.treeReader.right_field,
|
312
|
+
levelc = $t.p.treeReader.level_field,
|
313
|
+
lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
|
314
|
+
$(this.p.data).each(function(i){
|
315
|
+
if(parseInt(this[levelc],10) >= level && parseInt(this[lftc],10) >= lft && parseInt(this[lftc],10) <= rgt) {
|
316
|
+
result.push(this);
|
317
|
+
}
|
318
|
+
});
|
319
|
+
break;
|
320
|
+
case 'adjacency' :
|
321
|
+
result.push(rc);
|
322
|
+
var parent_id = $t.p.treeReader.parent_id_field,
|
323
|
+
dtid = $t.p.localReader.id;
|
324
|
+
$(this.p.data).each(function(i){
|
325
|
+
len = result.length;
|
326
|
+
for (i = 0; i < len; i++) {
|
327
|
+
if (result[i][dtid] == this[parent_id]) {
|
328
|
+
result.push(this);
|
329
|
+
break;
|
330
|
+
}
|
331
|
+
}
|
332
|
+
});
|
333
|
+
break;
|
334
|
+
}
|
335
|
+
});
|
336
|
+
return result;
|
337
|
+
},
|
338
|
+
// End NS, adjacency Model
|
339
|
+
getNodeAncestors : function(rc) {
|
340
|
+
var ancestors = [];
|
341
|
+
this.each(function(){
|
342
|
+
if(!this.grid || !this.p.treeGrid) { return; }
|
343
|
+
var parent = $(this).jqGrid("getNodeParent",rc);
|
344
|
+
while (parent) {
|
345
|
+
ancestors.push(parent);
|
346
|
+
parent = $(this).jqGrid("getNodeParent",parent);
|
347
|
+
}
|
348
|
+
});
|
349
|
+
return ancestors;
|
350
|
+
},
|
351
|
+
isVisibleNode : function(rc) {
|
352
|
+
var result = true;
|
353
|
+
this.each(function(){
|
354
|
+
var $t = this;
|
355
|
+
if(!$t.grid || !$t.p.treeGrid) { return; }
|
356
|
+
var ancestors = $($t).jqGrid("getNodeAncestors",rc),
|
357
|
+
expanded = $t.p.treeReader.expanded_field;
|
358
|
+
$(ancestors).each(function(){
|
359
|
+
result = result && this[expanded];
|
360
|
+
if(!result) {return false;}
|
361
|
+
});
|
362
|
+
});
|
363
|
+
return result;
|
364
|
+
},
|
365
|
+
isNodeLoaded : function(rc) {
|
366
|
+
var result;
|
367
|
+
this.each(function(){
|
368
|
+
var $t = this;
|
369
|
+
if(!$t.grid || !$t.p.treeGrid) { return; }
|
370
|
+
var isLeaf = $t.p.treeReader.leaf_field;
|
371
|
+
if(rc.loaded !== undefined) {
|
372
|
+
result = rc.loaded;
|
373
|
+
} else if( rc[isLeaf] || $($t).jqGrid("getNodeChildren",rc).length > 0){
|
374
|
+
result = true;
|
375
|
+
} else {
|
376
|
+
result = false;
|
377
|
+
}
|
378
|
+
});
|
379
|
+
return result;
|
380
|
+
},
|
381
|
+
expandNode : function(rc) {
|
382
|
+
return this.each(function(){
|
383
|
+
if(!this.grid || !this.p.treeGrid) { return; }
|
384
|
+
var expanded = this.p.treeReader.expanded_field;
|
385
|
+
if(!rc[expanded]) {
|
386
|
+
var id = $.jgrid.getAccessor(rc,this.p.localReader.id);
|
387
|
+
var rc1 = $("#"+id,this.grid.bDiv)[0];
|
388
|
+
var position = this.p._index[id];
|
389
|
+
if( $(this).jqGrid("isNodeLoaded",this.p.data[position]) ) {
|
390
|
+
rc[expanded] = true;
|
391
|
+
$("div.treeclick",rc1).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus");
|
392
|
+
} else {
|
393
|
+
rc[expanded] = true;
|
394
|
+
$("div.treeclick",rc1).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus");
|
395
|
+
this.p.treeANode = rc1.rowIndex;
|
396
|
+
this.p.datatype = this.p.treedatatype;
|
397
|
+
if(this.p.treeGridModel == 'nested') {
|
398
|
+
$(this).jqGrid("setGridParam",{postData:{nodeid:id,n_left:rc.lft,n_right:rc.rgt,n_level:rc.level}});
|
399
|
+
} else {
|
400
|
+
$(this).jqGrid("setGridParam",{postData:{nodeid:id,parentid:rc.parent_id,n_level:rc.level}});
|
401
|
+
}
|
402
|
+
$(this).trigger("reloadGrid");
|
403
|
+
if(this.p.treeGridModel == 'nested') {
|
404
|
+
$(this).jqGrid("setGridParam",{postData:{nodeid:'',n_left:'',n_right:'',n_level:''}});
|
405
|
+
} else {
|
406
|
+
$(this).jqGrid("setGridParam",{postData:{nodeid:'',parentid:'',n_level:''}});
|
407
|
+
}
|
408
|
+
}
|
409
|
+
}
|
410
|
+
});
|
411
|
+
},
|
412
|
+
collapseNode : function(rc) {
|
413
|
+
return this.each(function(){
|
414
|
+
if(!this.grid || !this.p.treeGrid) { return; }
|
415
|
+
if(rc.expanded) {
|
416
|
+
rc.expanded = false;
|
417
|
+
var id = $.jgrid.getAccessor(rc,this.p.localReader.id);
|
418
|
+
var rc1 = $("#"+id,this.grid.bDiv)[0];
|
419
|
+
$("div.treeclick",rc1).removeClass(this.p.treeIcons.minus+" tree-minus").addClass(this.p.treeIcons.plus+" tree-plus");
|
420
|
+
}
|
421
|
+
});
|
422
|
+
},
|
423
|
+
SortTree : function( sortname, newDir, st, datefmt) {
|
424
|
+
return this.each(function(){
|
425
|
+
if(!this.grid || !this.p.treeGrid) { return; }
|
426
|
+
var i, len,
|
427
|
+
rec, records = [], $t = this, query, roots,
|
428
|
+
rt = $(this).jqGrid("getRootNodes");
|
429
|
+
// Sorting roots
|
430
|
+
query = $.jgrid.from(rt);
|
431
|
+
query.orderBy(sortname,newDir,st, datefmt);
|
432
|
+
roots = query.select();
|
433
|
+
|
434
|
+
// Sorting children
|
435
|
+
for (i = 0, len = roots.length; i < len; i++) {
|
436
|
+
rec = roots[i];
|
437
|
+
records.push(rec);
|
438
|
+
$(this).jqGrid("collectChildrenSortTree",records, rec, sortname, newDir,st, datefmt);
|
439
|
+
}
|
440
|
+
$.each(records, function(index, row) {
|
441
|
+
var id = $.jgrid.getAccessor(this,$t.p.localReader.id);
|
442
|
+
$('#'+$t.p.id+ ' tbody tr:eq('+index+')').after($('tr#'+id,$t.grid.bDiv));
|
443
|
+
});
|
444
|
+
query = null; roots=null;records=null;
|
445
|
+
});
|
446
|
+
},
|
447
|
+
collectChildrenSortTree : function(records, rec, sortname, newDir,st, datefmt) {
|
448
|
+
return this.each(function(){
|
449
|
+
if(!this.grid || !this.p.treeGrid) { return; }
|
450
|
+
var i, len,
|
451
|
+
child, ch, query, children;
|
452
|
+
ch = $(this).jqGrid("getNodeChildren",rec);
|
453
|
+
query = $.jgrid.from(ch);
|
454
|
+
query.orderBy(sortname, newDir, st, datefmt);
|
455
|
+
children = query.select();
|
456
|
+
for (i = 0, len = children.length; i < len; i++) {
|
457
|
+
child = children[i];
|
458
|
+
records.push(child);
|
459
|
+
$(this).jqGrid("collectChildrenSortTree",records, child, sortname, newDir, st, datefmt);
|
460
|
+
}
|
461
|
+
});
|
462
|
+
},
|
463
|
+
// experimental
|
464
|
+
setTreeRow : function(rowid, data) {
|
465
|
+
var success=false;
|
466
|
+
this.each(function(){
|
467
|
+
var t = this;
|
468
|
+
if(!t.grid || !t.p.treeGrid) { return; }
|
469
|
+
success = $(t).jqGrid("setRowData",rowid,data);
|
470
|
+
});
|
471
|
+
return success;
|
472
|
+
},
|
473
|
+
delTreeNode : function (rowid) {
|
474
|
+
return this.each(function () {
|
475
|
+
var $t = this;
|
476
|
+
if(!$t.grid || !$t.p.treeGrid) { return; }
|
477
|
+
var rc = $($t).jqGrid("getInd",rowid,true);
|
478
|
+
if (rc) {
|
479
|
+
var dr = $($t).jqGrid("getNodeChildren",rc);
|
480
|
+
if(dr.length>0){
|
481
|
+
for (var i=0;i<dr.length;i++){
|
482
|
+
$($t).jqGrid("delRowData",dr[i].id);
|
483
|
+
}
|
484
|
+
}
|
485
|
+
$($t).jqGrid("delRowData",rc.id);
|
486
|
+
}
|
487
|
+
});
|
488
|
+
}
|
489
|
+
});
|
483
490
|
})(jQuery);
|