【问题标题】:Filter toolbar: data getting trimmed in free jqGrid过滤器工具栏:在免费 jqGrid 中修剪数据
【发布时间】:2016-02-08 17:58:08
【问题描述】:

我们有一个填充为四个字符的数据字段..
例如,您可以使用“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;

【问题讨论】:

    标签: jquery jqgrid free-jqgrid


    【解决方案1】:

    非常感谢您的错误报告!

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

    【讨论】:

    • @RichT.:不客气!也感谢您的错误报告。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-14
    • 2013-05-21
    相关资源
    最近更新 更多