Skip to content

Commit a9c8c63

Browse files
committed
Fix the bug in filtering if cm.name!=cm.index
Thanks @davgino for reporting the bug. See free-jqgrid#216 for more details.
1 parent ccdb0d4 commit a9c8c63

18 files changed

+730
-695
lines changed

js/grid.celledit.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@
145145
}
146146
}
147147
feedback.call($t, "beforeEditCell", rowid, nm, tmp, iRow, iCol);
148-
var opt = $.extend({}, cm.editoptions || {}, { id: iRow + "_" + nm, name: nm, rowId: rowid, mode: mode });
148+
var opt = $.extend({}, cm.editoptions || {},
149+
{ id: iRow + "_" + nm, name: nm, rowId: rowid, mode: mode, cm: cm, iCol: iCol });
149150
var elc = jgrid.createEl.call($t, edittype, opt, tmp, true, $.extend({}, jgrid.ajaxOptions, p.ajaxSelectOptions || {})),
150151
$dataFiled = cc,
151152
editingColumnWithTreeGridIcon = p.treeGrid === true && nm === p.ExpandColumn;

js/grid.common.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,8 @@
423423
break;
424424
case "select":
425425
elem = document.createElement("select");
426-
var msl, ovm = [], iCol = p.iColByName[options.name], cm = p.colModel[iCol], isSelected;
426+
var msl, ovm = [], isSelected;
427427

428-
if (cm == null) { return ""; }
429428
if (options.multiple === true) {
430429
msl = true;
431430
elem.multiple = "multiple";
@@ -441,7 +440,7 @@
441440
}
442441
if (options.dataUrl !== undefined) {
443442
var rowid = null, postData = options.postData || ajaxso.postData,
444-
ajaxContext = { elem: elem, options: options, cm: cm, iCol: iCol, ovm: ovm };
443+
ajaxContext = { elem: elem, options: options, cm: options.cm, iCol: options.iCol, ovm: ovm };
445444
try {
446445
rowid = options.rowId;
447446
} catch (ignore) { }
@@ -488,7 +487,7 @@
488487
elem: elem1,
489488
options: options1,
490489
cm: cm1,
491-
cmName: cm1.name,
490+
cmName: cm1 != null ? cm1.name : options1.name,
492491
iCol: iCol1
493492
});
494493
}, 0);
@@ -559,9 +558,9 @@
559558
jgrid.fullBoolFeedback.call($t, options.selectFilled, "jqGridSelectFilled", {
560559
elem: elem,
561560
options: options,
562-
cm: cm,
563-
cmName: cm.name,
564-
iCol: iCol
561+
cm: options.cm,
562+
cmName: options.cm != null ? options.cm.name : options.name,
563+
iCol: options.iCol
565564
});
566565
}
567566
break;

js/grid.filter.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@
9797
getRes = function (property) {
9898
return $(getGrid()).jqGrid("getGridRes", "search." + property);
9999
},
100+
getCmInfo = function (cmName) {
101+
// the function convert column name or advanced property name to
102+
// object with properties { cm: , iCol: }
103+
var $t = getGrid(), iCol = $t.p.iColByName[cmName]; //iPropByName
104+
if (iCol !== undefined) {
105+
return { cm: $t.p.colModel[iCol], iCol: iCol };
106+
}
107+
iCol = $t.p.iPropByName[cmName];
108+
if (iCol !== undefined) {
109+
return { cm: $t.p.colModel[iCol], iCol: iCol, isAddProp: true };
110+
}
111+
return { cm: null, iCol: -1 };
112+
},
100113
errorClass = getGuiStyles("states.error"),
101114
dialogContentClass = getGuiStyles("dialog.content");
102115

@@ -126,6 +139,7 @@
126139
if (!cl.label) {
127140
cl.label = cl.name;
128141
}
142+
cl.cmName = cl.name;
129143
if (cl.index) {
130144
cl.name = cl.index;
131145
}
@@ -381,6 +395,7 @@
381395
{},
382396
columns.editoptions || {},
383397
columns.searchoptions || {},
398+
getCmInfo(columns.cmName),
384399
{ id: jgrid.randId(), name: columns.name, mode: "search" }
385400
);
386401
if (isIE && columns.inputtype === "text") {
@@ -477,7 +492,7 @@
477492
}
478493
}
479494
var ruleDataInput = jgrid.createEl.call($t, cm.inputtype,
480-
$.extend({}, cm.editoptions || {}, cm.searchoptions || {}, { id: jgrid.randId(), name: cm.name }),
495+
$.extend({}, cm.editoptions || {}, cm.searchoptions || {}, getCmInfo(cm.cmName), { id: jgrid.randId(), name: cm.name }),
481496
rule.data, true, that.p.ajaxSelectOptions || {}, true);
482497
if (rule.op === "nu" || rule.op === "nn") {
483498
$(ruleDataInput).attr("readonly", "true");

js/grid.formedit.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,8 @@
594594
}
595595
if (isEmptyString(tmp)) { tmp = ""; }
596596
}
597-
var opt = $.extend({}, cm.editoptions || {}, { id: nm, name: nm, rowId: rowid1, mode: mode }),
597+
var opt = $.extend({}, cm.editoptions || {},
598+
{ id: nm, name: nm, rowId: rowid1, mode: mode, cm: cm, iCol: iCol }),
598599
frmopt = $.extend({}, { elmprefix: "", elmsuffix: "", rowabove: false, rowcontent: "" }, cm.formoptions || {}),
599600
rp = parseInt(frmopt.rowpos, 10) || cnt + 1,
600601
cp = parseInt((parseInt(frmopt.colpos, 10) || 1) * 2, 10);

js/grid.inlinedit.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@
110110
}
111111
svr[nm] = tmp; // include only editable fields in svr object
112112
$dataFiled.html("");
113-
opt = $.extend({}, editoptions, { id: rowid + "_" + nm, name: nm, rowId: rowid, mode: options.mode });
113+
opt = $.extend({}, editoptions,
114+
{ id: rowid + "_" + nm, name: nm, rowId: rowid, mode: options.mode, cm: cm, iCol: iCol });
114115
if (tmp === " " || tmp === " " || (tmp.length === 1 && tmp.charCodeAt(0) === 160)) { tmp = ""; }
115116
elc = jgrid.createEl.call($t, edittype, opt, tmp, true, $.extend({}, jgrid.ajaxOptions, p.ajaxSelectOptions || {}));
116117
$(elc).addClass("editable");

0 commit comments

Comments
 (0)