过滤器工具栏:在免费的 jqGrid 中修剪数据
Filter toolbar: data getting trimmed in free jqGrid
我们有一个填充为四个字符的数据字段..
例如,您可以使用 "ABC " 或 "DEFG"。此数据用作过滤器工具栏中 select 下拉列表的值。
构建过滤器时,将修剪填充;所以 "ABC " 现在是 "ABC".. 所以中间层的过滤失败了.. "ABC" != "ABC "
我修改了 jqgrid 源代码以删除修剪,这样安全吗?它解决了我的问题,但我不清楚我是否在制造更多问题。
/* the format of element of the searching toolbar if ANOTHER
* as the format of cells in the grid. So one can't use
* value = $.unformat.call($t, $elem, { colModel: cm }, iCol)
* to get the value. Even the access to the value should be
* $elem.val() instead of $elem.text() used in the common case of
* formatter. So we have to make manual conversion of searching filed
* used for integer/number/currency. The code will be duplicate */
if (cm.stype === "custom" && $.isFunction(searchoptions.custom_value) && $elem.length > 0 && $elem[0].nodeName.toUpperCase() === "SPAN") {
v = searchoptions.custom_value.call($t, $elem.children(".customelement").first(), "get");
} else {
//v = $.trim($elem.val()); // *** commented this out ***
v = $elem.val();
switch (cm.formatter) {
case "integer":
v = cutThousandsSeparator(v)
.replace(getFormaterOption("decimalSeparator", "number"), ".");
if (v !== "") {
// normalize the strings like "010.01" to "10"
v = String(parseInt(v, 10));
}
break;
case "number":
v = cutThousandsSeparator(v)
.replace(getFormaterOption("decimalSeparator"), ".");
if (v !== "") {
// normalize the strings like "010.00" to "10"
// and "010.12" to "10.12"
v = String(parseFloat(v));
}
break;
非常感谢您的错误报告!
这似乎是一个但是,但是只有在 stype: "select"
的情况下才应该跳过 $.trim
更好。它将减少其他情况的副作用。我将更改提交给 GitHub(参见 here)。
我们有一个填充为四个字符的数据字段..
例如,您可以使用 "ABC " 或 "DEFG"。此数据用作过滤器工具栏中 select 下拉列表的值。
构建过滤器时,将修剪填充;所以 "ABC " 现在是 "ABC".. 所以中间层的过滤失败了.. "ABC" != "ABC "
我修改了 jqgrid 源代码以删除修剪,这样安全吗?它解决了我的问题,但我不清楚我是否在制造更多问题。
/* the format of element of the searching toolbar if ANOTHER
* as the format of cells in the grid. So one can't use
* value = $.unformat.call($t, $elem, { colModel: cm }, iCol)
* to get the value. Even the access to the value should be
* $elem.val() instead of $elem.text() used in the common case of
* formatter. So we have to make manual conversion of searching filed
* used for integer/number/currency. The code will be duplicate */
if (cm.stype === "custom" && $.isFunction(searchoptions.custom_value) && $elem.length > 0 && $elem[0].nodeName.toUpperCase() === "SPAN") {
v = searchoptions.custom_value.call($t, $elem.children(".customelement").first(), "get");
} else {
//v = $.trim($elem.val()); // *** commented this out ***
v = $elem.val();
switch (cm.formatter) {
case "integer":
v = cutThousandsSeparator(v)
.replace(getFormaterOption("decimalSeparator", "number"), ".");
if (v !== "") {
// normalize the strings like "010.01" to "10"
v = String(parseInt(v, 10));
}
break;
case "number":
v = cutThousandsSeparator(v)
.replace(getFormaterOption("decimalSeparator"), ".");
if (v !== "") {
// normalize the strings like "010.00" to "10"
// and "010.12" to "10.12"
v = String(parseFloat(v));
}
break;
非常感谢您的错误报告!
这似乎是一个但是,但是只有在 stype: "select"
的情况下才应该跳过 $.trim
更好。它将减少其他情况的副作用。我将更改提交给 GitHub(参见 here)。