【问题标题】:Set custom search options in JQGrid在 JQGrid 中设置自定义搜索选项
【发布时间】:2014-03-10 13:09:36
【问题描述】:

请看一下这张图片。

在下拉列表中是搜索选项的集合。我想要的是将这些选项缩减为仅相等和不相等。我不希望显示其他选项。我试过做 但它不起作用。任何帮助表示赞赏。

navGrid("#pager", {search:true, edit:false,add:false,del:false,searchtext:"Search",refreshtext:"Refresh" },
                  {sopt: ['eq','ne']}      
       );

【问题讨论】:

    标签: jquery search jqgrid


    【解决方案1】:
     jQuery("#dataTable").jqGrid('navGrid','#pagingDiv',
                {
                    search:true,
                    edit:false,
                    add:false,
                    del:false
                },
                {},
                {},
                {},
                {
                    multipleSearch:false, multipleGroup:false, showQuery: false,
                    sopt: ['eq', 'ne', 'cn', 'nc', 'bw', 'ew'],
                    defaultSearch: 'cn'
                    //optDescriptions: {eq:'my eq', gt:'after', le:'on or before'}
                }
    
                );
    

    【讨论】:

      【解决方案2】:

      Based on this (link)

      navGrid("#pager", 
      {
          search:true, 
          edit:false,
          add:false,
          del:false,
          searchtext:"Search",
          refreshtext:"Refresh",
          searchoptions:{
                            sopt: ['eq','ne']
                        }
      });
      

      【讨论】:

      • 这段代码和我已经尝试过的唯一区别是使用了searchoptions,添加之后并没有达到我想要的效果..
      【解决方案3】:

      为 jqgrid 中的过滤器搜索选项添加此 sopt:['eq','ne'] 条件。

      jqgrid 中可用的搜索选项总数为

      sopt:['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']
      

      替换下面的代码:

      $("#listCountry").jqGrid('navGrid','#pagerDiv',
      {edit:false,add:false,del:false},{},{},{},{sopt:['eq','ne']});
      

      脚本:

      $(document).ready(function(){
      
          //jqGrid
          $("#listCountry").jqGrid({
              url:'<%=request.getContextPath()%>/Admin/getCountriesList',
              datatype: "json",           
              colNames:['Edit','Country Code','Country Name','Active'],
              colModel:[                  
                  {name:'countryId',search:false, index:'countryId', width:30,sortable: false, formatter: editLink},                  
                  {name:'countryCode',index:'countryCode', width:100},
                  {name:'countryName',index:'countryName',width:250}, 
                  {name:'isActive',index:'isActive',width:80},
                  ],
                  rowNum:20,
                  rowList:[10,20,30,40,50],
                  rownumbers: true,  
                  pager: '#pagerDiv', headertitles:true,
                  sortname: 'countryName',  
                  viewrecords: true,  
                  sortorder: "asc",              
          });
          $('#gridContainer div:not(.ui-jqgrid-titlebar)').width("100%");
          $('.ui-jqgrid-bdiv').css('height', window.innerHeight * .65);                   
          $('#load_listCountry').width("130");    
          $("#listCountry").jqGrid('navGrid','#pagerDiv',{edit:false,add:false,del:false},{},{},{},{sopt:['eq','ne']});
          $(".inline").colorbox({inline:true, width:"20%"});
      });
      
      function editLink(cellValue, options, rowdata, action) {
          return "<a href='<%=request.getContextPath()%>/Admin/addCountry/"+ rowdata.countryId + "' title='Edit' class='ui-icon ui-icon-pencil' ></a>";
      }
      

      HTML

      <div id="gridContainer">
          <table id="listCountry"></table>
          <div id="pagerDiv"></div>
      </div>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多