默认情况下,在jqGrid中使用工具栏搜索在列的中间搜索

时间:2011-03-31 12:42:22

标签: search jqgrid wildcard

在阅读了jqGrid wiki(并从Case insensitive search in jqGrid including hidden fields获取示例)之后,我找不到我想要做的事情。

是否有任何搜索选项可以在列中的任何位置启用搜索(自动通配符)。

如果该栏中包含“Apple Iphone”,我可以使用搜索“iphone”找到它。

SQL等效项为select * from table where lower(columnX) like '%iphone%';

3 个答案:

答案 0 :(得分:18)

由于您使用toolbar searching,问题的解决方案似乎很简单。你应该:

  1. ignoreCase:true包含在jqGrid参数
  2. filterToolbar的来电中加入defaultSearch:'cn'选项。例如:$("#list").jqGrid('filterToolbar', {defaultSearch:'cn'})
  3. 如果您在搜索工具栏中使用任何选择元素(stype:'select'),则应在searchoptions {emp'开头的sopt选项列表中加入:{{1}例如。

答案 1 :(得分:1)

$(document).ready(function() {
  colNamesData = [ 'Description']

  {name:'description',index:'description', width:130, sorttype:"text", search:true, editable:true, edittype:"textarea", editoptions: {rows:"5",cols:"25",maxlength:"255"}, stype:'text', searchoptions:{sopt:['cn', 'nc', 'bw', 'bn', 'ew', 'en']}},

$("#description_table").jqGrid({
      datatype: "local", 
      height: "auto",
      autowidth: true,
      ignoreCase: true,
      colNames: colNamesData, 
      colModel: colModelHash,
      pager: '#pager',
      rowNum:10,
      rowList:[10,25,50,100],
      sortname: 'date',
      sortorder: 'desc',
      viewrecords: true,
      editurl:"/url_name.json", 
      caption: 'Description'
 data:<%= raw @jqgrid_table.to_json %>
   });

   jQuery("#description_table").jqGrid('navGrid','#pager',{del:false,add:true,edit:false},{}, {modal: true,afterSubmit:processAddEdit,recreateForm:true, afterComplete:reloadJqGrid}, {modal: true}, {multipleSearch:true});  

现在,如果你的文字包含“我在这里”,如果你搜索“go”,它肯定会搜索,它对我有用。

如果没有,请尝试回复。

答案 2 :(得分:1)

$("#list").jqGrid('filterToolbar', {stringResult: true, searchOnEnter: false, defaultSearch : "cn"});

在上面的示例中,**defaultSearch : "cn"**用于使用您要搜索的项目的任何子字符串进行搜索。删除defaultSearch : "cn"从子字符串开始搜索。

相关问题