2014-03-12 54 views
1

JqGrid默认搜索对话框中是否有任何选项可用于增加搜索中文本框的宽度。JQGrid默认搜索对话框,输入字段宽度

下面是图片:

Search Box

更新代码为我的搜索如下:

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的选择,因为真正的在我的网格,因此我所有的搜索是本地的,并且不进行服务器调用。

回答

1

你应该使用beforeShowSearch & afterRedraw事件改变风格。

beforeShowSearch会在搜索对话框显示为 之前触发,并且在添加新搜索参数时激发Redraw之后触发。

我修改了代码。 $(".searchFilter table td .input-elm")searchFilter是类的父DIV和输入榆树是类文本框。 300像素只是一个数字我放弃,可随时更改,以适应你的变化:

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; 
     } 
    }); 
+0

感谢@avijendr但加入后beforeShowSearch我的搜索对话框是不开放。我检查铬控制台,也没有错误。 – nido

+0

@nido - 这是jqgrid中的错误(在4.4中介绍)。我更新了答案您必须在beforeShowSearch中返回true。请让我知道这是否有效。它适用于我本地! – avijendr

+0

真棒,那就像一个魅力。谢谢! – nido