【问题标题】:JQGrid default Search Dialog, input fields widthJQGrid 默认搜索对话框,输入字段宽度
【发布时间】:2014-03-12 14:51:37
【问题描述】:

Jqgrid 默认搜索对话框中是否有任何选项可以增加搜索中文本框的宽度。

这是图片:

更新我的搜索代码如下:

jQuery("#subscriptions").jqGrid(
    'navGrid',
    '#pager',
    { del: false, add: false, edit: false },
    {},
    {},
    {},
    {
        multipleSearch: true,
        closeAfterSearch: true,
        beforeShowSearch: function ($form) {
            $(".searchFilter table td .input-elm").attr('style', 'width:400px');
            $('#searchmodfbox_subscriptions').width(750);
            return true;
        },
        afterRedraw: function ($form) {
            $(".searchFilter table td .input-elm").attr('style', 'width:400px');
            return true;
        }
    });

我还在我的网格中使用 loadonce 选项作为 true,因此我所有的搜索都是本地的,并且没有进行服务器调用。

【问题讨论】:

    标签: javascript jquery css jqgrid


    【解决方案1】:

    您应该使用 beforeShowSearchafterRedraw 事件更改样式。

    beforeShowSearch 每次在搜索对话框出现之前触发 在添加新的搜索参数时显示和 afterRedraw 被触发。

    我已经用它修改了代码。 $(".searchFilter table td .input-elm") 其中 searchFilter 是父 div 的类,input-elm 是文本框的类。 300px 只是我给出的一个数字,请随意更改以适应您的更改:

    jQuery("#subscriptions").jqGrid(
        'navGrid',
        '#pager',
        { del: false, add: false, edit: false },
        {},
        {},
        {},
        {
            multipleSearch: true,
            closeAfterSearch: true,
            beforeShowSearch: function($form) {
               $(".searchFilter table td .input-elm").attr('style','width:300px');
               return true;
            },
            afterRedraw: function($form) {
              $(".searchFilter table td .input-elm").attr('style','width:300px');
              return true;
            }
        }); 
    

    【讨论】:

    • 感谢@avijendr,但在添加 beforeShowSearch 之后,我的搜索对话框没有打开。我检查了chrome控制台,也没有错误。
    • @nido - 这是 jqgrid 中的一个错误(在 4.4 中引入)。我更新了答案你必须在 beforeShowSearch 中返回 true。请让我知道这是否有效。它在本地对我有用!
    • 还有一件事;第一次确实增加了输入字段的长度,但是当我更改搜索条件时,它又将其移回原来的大小,是否可以全部更新?
    • @nido 我会尽快回复。
    • @nido 我已经用解决方案更新了答案。这个技巧是由“afterRedraw”事件完成的。我建议您保留一个用于更改大小的通用函数并在两个事件中调用它。
    猜你喜欢
    • 2011-12-05
    • 1970-01-01
    • 1970-01-01
    • 2013-04-29
    • 2011-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多