过滤器工具栏:在自由jqGrid中修剪数据

时间:2016-02-08 17:58:08

标签: jquery jqgrid free-jqgrid

我们有一个填充到四个字符的数据字段。
例如,您可以使用“ABC”或“DEFG”。此数据用作过滤器工具栏中选择下拉列表的值。

构建过滤器时,填充物会被修剪掉;所以“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;

1 个答案:

答案 0 :(得分:1)

非常感谢您的错误报告!

似乎是一个但是,但只有在$.trim的情况下,才能更好地跳过stype: "select"。它会减少其他病例的副作用。我将更改提交给GitHub(请参阅here)。