【问题标题】:Filtering in <sjg:grid> without case sensitivity在不区分大小写的情况下过滤 <sjg:grid>
【发布时间】:2012-06-25 07:36:29
【问题描述】:

我正在使用一个 struts2jquery 网格,其中我给出了 filter="true"。所以它在客户端过滤数据。但它只过滤大小写敏感。我需要在没有大小写的情况下获取数据。那么我应该为此添加什么。期待一些建议。谢谢!!!

【问题讨论】:

    标签: java jqgrid struts2


    【解决方案1】:

    我找到了使用 javaScript 的解决方案:

    <%@ taglib prefix="s" uri="/struts-tags"%>
    <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
    <%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>
    
       <s:url var="remoteurl" action="jsontable" />
    
        <sjg:grid id="gridtableID" 
    
            caption="Primjer JSON TABELE" 
            dataType="json"
            href="%{remoteurl}" 
            gridModel="gridModel" 
            viewrecords="true"
            pager="true"
            pagerPosition="centar"
            navigator="true"
            navigatorSearch="true"
            filter="true"
            filterOptions="{stringResult:true}"
            loadonce="true"
    
             >
    
            <sjg:gridColumn name="id"
                index="id" title="ID" 
                formatter="integer"
                search="false"
                searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}"
                editable="false" />
            <sjg:gridColumn name="name" index="name" title="Name" sortable="true"
                search="true"
                searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}" />
            <sjg:gridColumn name="country" index="country" title="Country"
                search="true"
                searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}"/>
            <sjg:gridColumn name="city" index="city" title="City" search="true"
                searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}" />
            <sjg:gridColumn name="creditLimit" index="creditLimit"
                title="Credit Limit" formatter="currency" search="true"
                searchoptions="{sopt:['cn','eq','ne','bw','bn','ew','en','nc']}"/>
    
        </sjg:grid>
    
        <script>
        $(document).ready(function(){
            $("#gridtableID").jqGrid('setGridParam', { ignoreCase: true});
            });
        </script>
    

    【讨论】:

      【解决方案2】:

      这可能有点晚了,但这里有一个更简单的解决方案:

      第 1 步: 将 onCompleteTopics 添加到 sgj:grid 标签。

      <sjg:grid
      ...
      onCompleteTopics="loadComplete"
      ...
      >
      

      第 2 步: 将 .subscribe 添加到您的 .jsp 中,其中包含以下代码。

      <script>
          $.subscribe('loadComplete', function (event, data){
               $("#gridtable").jqGrid('setGridParam', { ignoreCase: true});
          });
      </script>
      

      这应该会关闭网格顶部过滤器行的区分大小写。这仅用于客户端过滤。

      【讨论】:

        猜你喜欢
        • 2020-07-22
        • 1970-01-01
        • 2019-05-22
        • 1970-01-01
        • 1970-01-01
        • 2019-06-26
        • 2013-08-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多