2015-01-06 24 views
0

아래 예와 같이 숫자 열을 검색 할 때 : 연간 청구액 : $ 7,749.19
입력하면 검색 기능이 내장 검색 기능에 표시되지 않습니다. 7749.19 그러나검색 기능이 쉼표 등을 무시하게하는 몇 가지 매개 변수가 있어야합니다. $ 내가 조사했지만 어떻게 할 수 있는지 찾을 수 없었습니다. 당신이 날 내가 대문자, 소문자, 등 $, 쉼표를 무시하는 검색 작업을 할 수있는 방법을 알려 수 있다면 감사하겠습니다

내 코드는 참조를 위해 아래에 주어진

:

 $("#tblSiteLookup").jqGrid({ 

       url: 'Handlers/SitesHandler.ashx?l=sa&site=family&initiativeId=' + gblInitiativeID, 
       datatype: "json", 
       height: 250, 
       width: 600, 
       // autowidth: true, 
       shrinkToFit: false, 
       //forceFit: true, 
       mtype: 'post', 
       loadonce: true, 
       colNames: ['CompanyGuid', 'Company', 'SiteGuid', 'Customer Site ID', 'Site Common Name', 'Service Street Address', 'Service City', 'Annual Consumption (kWh)', 'Annual Billing', 'OwnerId'], 
       colModel: [ 
          { name: 'CompanyGuid', hidden: true, sortable: false, editable: true }, 
          { name: 'Company', search: true, width: 160, sortable: true, editable: true }, 
          { name: 'SiteGuid', hidden: true, sortable: false, editable: true }, 
          { name: 'CustomerSite', search: true, width: 100, sortable: true, editable: true }, 
          { name: 'CommonName', search: true, width: 200, sortable: true, editable: true }, 
          { name: 'StreetAddress', search: true, width: 250, sortable: true, editable: true }, 
          { name: 'City', search: true, width: 110, sortable: true, editable: true }, 
          { name: 'AnnualConsumption', search: true, width: 150, sortable: true, editable: true }, 
          { name: 'AnnualBilling', search: true, width: 100, sortable: true, editable: true }, 
          { name: 'OwnerId', hidden: true, sortable: false, editable: true }, 
       ], 
       rowNum: 10, 
       rowList: [10, 20, 30], 
       pager: '#pager11', 
       sortname: 'Company', 
       viewrecords: true, 
       sortorder: "desc", 
       caption: "Site" 
      }); 

      $("#tblSiteLookup").jqGrid("setLabel", "Company", "", { "text-align": "left" }); 
      $("#tblSiteLookup").jqGrid("setLabel", "CustomerSite", "", { "text-align": "left" }); 
      $("#tblSiteLookup").jqGrid("setLabel", "CommonName", "", { "text-align": "left" }); 
      $("#tblSiteLookup").jqGrid("setLabel", "StreetAddress", "", { "text-align": "left" }); 
      $("#tblSiteLookup").jqGrid("setLabel", "City", "", { "text-align": "left" }); 
      $("#tblSiteLookup").jqGrid("setLabel", "AnnualConsumption", "", { "text-align": "left" }); 
      $("#tblSiteLookup").jqGrid("setLabel", "AnnualBilling", "", { "text-align": "left" }); 

      $("#tblSiteLookup").jqGrid('navGrid', '#pager11', { search: true, edit: false, add: false, del: false, searchtext: "search", refresh: false }); 


Server Side code : 
using System; 
using System.Collections; 
using System.Collections.Generic; 
using System.Collections.ObjectModel; 
using System.Linq; 
using System.Data; 
using System.Data.SqlClient; 
using System.Web; 
using System.Web.SessionState; 
using System.Web.Script.Serialization; 
using System.ServiceModel.Description; 
using Microsoft.Xrm.Sdk.Client; 
using Microsoft.Xrm.Sdk.Query; 
using System.Net; 
using Microsoft.Xrm.Sdk; 
using ESRCommon; 
using ESRBusiness; 
using ESRDomain; 
using Microsoft.Crm.Sdk.BchXrm; 
using BCH.DSM.XRM.Common; 

namespace ESRWeb.Handlers 
{ 
    /// <summary> 
    /// Summary description for SitesHandler 
    /// </summary> 
    public class SitesHandler : IHttpHandler , IRequiresSessionState 
    { 

     #region Global Members 

      private string _search = string.Empty; 
      private int _numberOfRows = 0; 
      private int _pageIndex = 0; 
      private string _sortColumnName = string.Empty; 
      private string _sortOrderBy = string.Empty; 
      private string _command = string.Empty; 
      private string _strOperation = string.Empty; 
      private string _site = string.Empty; 
      private string _initiativeId = string.Empty; 

     #endregion 
     /// <summary> 
     /// Handle the request 
     /// </summary> 
     /// <param name="context"></param> 
     public void ProcessRequest(HttpContext context) 
     { 
      HttpRequest request = context.Request; 
      HttpResponse response = context.Response; 
      System.Collections.Specialized.NameValueCollection forms = context.Request.Form; 
      string SessionData = string.Empty; 
      string sitesList = string.Empty; 

      if (context.Session["SessionData"] == null) 
      { 
       context.Session["SessionData"] = "MySessionData"; 
      } 
      else 
      { 
       SessionData = (string)context.Session["SessionData"]; 
      } 


      _command = (request["l"] != null) ? request["l"] : "sa"; 
      _strOperation = forms.Get("oper"); 
      _site = (request["site"] != null) ? request["site"] : string.Empty; 
      _initiativeId = (request["initiativeId"] != null) ? request["initiativeId"] : string.Empty; 

      _search = (request["search"] != null) ? request["search"] : string.Empty; 

      if (_strOperation == null) 
      { 
       if (_command == "sa" && _site == "family" && !String.IsNullOrEmpty(_initiativeId) && _initiativeId != "undefined") 
       { 
        Guid initId = Guid.Parse(_initiativeId); 
        sitesList = GetSitesListByFamily(initId); 
        response.Write(sitesList); 
       } 

       if (_site == "all") 
       { 
        sitesList = GetSitesList(); 
        response.Write(sitesList); 
       } 

       if (_site == "query" && !String.IsNullOrEmpty(_search)) 
       { 
        sitesList = GetSitesList(_search); 
        response.Write(sitesList); 
       } 

      } 
     }   

     private string GetSitesList(string _search) 
     { 
      XrmBusinessManager eum = new XrmBusinessManager(); 
      List<JsonSite> jsonListSites = new List<JsonSite>(); 
      JQGridResults result = new JQGridResults(); 
      List<JQGridRow> rows = new List<JQGridRow>(); 
      JQGridRow row = new JQGridRow(); 
      int id = 0; 

      // Get the list of Sites 
      jsonListSites.AddRange(eum.GetSitesListBL(_search)); 

      if (jsonListSites.Count > 0) 
      { 
       foreach (JsonSite site in jsonListSites) 
       { 
        row.id = id; 
        id++; 
        row.cell = new string[10]; 

        row.cell[0] = site.guid.ToString(); //hidden column 
        row.cell[1] = site.company; 
        row.cell[2] = site.bchSiteid.ToString(); //hidden column 
        row.cell[3] = site.bchName; 
        row.cell[4] = site.bchSiteCommonName; 
        row.cell[5] = site.bchServiceAddressLine1; 
        row.cell[6] = site.bchServiceAddressCity; 

        row.cell[7] = site.bchAnnualElectricConsumptionKwh; 
        row.cell[8] = site.bchAnnualBillingBase; 
        row.cell[9] = site.bchOwner; 


        rows.Add(row); 
       } 
      } 

      // Total number of pages 
      int total_pages = 0; 
      _numberOfRows = 10; 
      if (rows.Count > 0) 
       total_pages = (rows.Count + _numberOfRows - 1)/_numberOfRows; 


      result.rows = rows.ToArray(); 
      result.page = _pageIndex; 
      result.total = total_pages; 
      result.records = rows.Count; 

      return new JavaScriptSerializer().Serialize(result); 
     } 

     private string GetSitesList() 
     { 
      XrmBusinessManager eum = new XrmBusinessManager(); 
      List<JsonSite> jsonListSites = new List<JsonSite>(); 
      JQGridResults result = new JQGridResults(); 
      List<JQGridRow> rows = new List<JQGridRow>(); 
      JQGridRow row = new JQGridRow(); 
      int id = 0; 

      // Get the list of Sites 
      jsonListSites.AddRange(eum.GetSitesListBL()); 

      if (jsonListSites.Count > 0) 
      { 
       foreach (JsonSite site in jsonListSites) 
       { 
        row.id = id; 
        id++; 
        row.cell = new string[10]; 

        row.cell[0] = site.guid.ToString(); //hidden column 
        row.cell[1] = site.company; 
        row.cell[2] = site.bchSiteid.ToString(); //hidden column 
        row.cell[3] = site.bchName; 
        row.cell[4] = site.bchSiteCommonName; 
        row.cell[5] = site.bchServiceAddressLine1; 
        row.cell[6] = site.bchServiceAddressCity; 

        row.cell[7] = site.bchAnnualElectricConsumptionKwh; 
        row.cell[8] = site.bchAnnualBillingBase; 
        row.cell[9] = site.bchOwner; 


        rows.Add(row); 
       } 
      } 

      // Total number of pages 
      int total_pages = 0; 
      _numberOfRows = 10; 
      if (rows.Count > 0) 
       total_pages = (rows.Count + _numberOfRows - 1)/_numberOfRows; 


      result.rows = rows.ToArray(); 
      result.page = _pageIndex; 
      result.total = total_pages; 
      result.records = rows.Count; 

      return new JavaScriptSerializer().Serialize(result); 
     } 

     /// <summary> 
     /// Get the list of Sites in a JQ Grid 
     /// </summary> 
     /// <returns>JQ Grid of End Uses</returns> 
     private string GetSitesListByFamily(Guid initiativeId) 
     { 
      XrmBusinessManager eum = new XrmBusinessManager(); 
      List<JsonSite> jsonListSites = new List<JsonSite>(); 
      JQGridResults result = new JQGridResults(); 
      List<JQGridRow> rows = new List<JQGridRow>(); 
      JQGridRow row = new JQGridRow(); 
      int id = 0; 

      // Get the list of Sites 
      jsonListSites.AddRange(eum.GetSitesListByFamilyBL(initiativeId)); 

      if (jsonListSites.Count > 0) 
      { 
       foreach (JsonSite site in jsonListSites) 
       { 
        row.id = id; 
        id++; 
        row.cell = new string[10];     

        row.cell[0] = site.guid.ToString(); //hidden column 
        row.cell[1] = site.company; 
        row.cell[2] = site.bchSiteid.ToString(); //hidden column 
        row.cell[3] = site.bchName; 
        row.cell[4] = site.bchSiteCommonName; 
        row.cell[5] = site.bchServiceAddressLine1; 
        row.cell[6] = site.bchServiceAddressCity; 

        row.cell[7] = site.bchAnnualElectricConsumptionKwh; 
        row.cell[8] = site.bchAnnualBillingBase; 
        row.cell[9] = site.bchOwner; 


        rows.Add(row); 
       } 
      } 

      // Total number of pages 
      int total_pages = 0; 
      _numberOfRows = 10; 
      if (rows.Count > 0) 
       total_pages = (rows.Count + _numberOfRows - 1)/_numberOfRows; 


      result.rows = rows.ToArray(); 
      result.page = _pageIndex; 
      result.total = total_pages; 
      result.records = rows.Count; 

      return new JavaScriptSerializer().Serialize(result); 
     } 

     public bool IsReusable 
     { 
      // To enable pooling, return true here. 
      // This keeps the handler in memory. 
      get { return false; } 
     } 
    } 

} 
+0

우리는 서버 측 코드를 볼 수 있습니까? 귀하의 코드에 따르면 서식을 무시할지 여부는 서버에 달려 있습니다. –

+0

안녕하세요 서버 측 코드가 추가되었습니다. – Ruruboy

+0

검색은'XrmBusinessManager' 클래스의'GetSitesListBL (_search)'메소드에 있어야한다고 생각합니다. –

답변

0

당신이 할 수있는 jquery.jqGrid.src.js의 일부 라인을 변경하여이 작업을 수행하십시오.

4116 라인을 사용자의 요구 사항을 충족하도록 교체하십시오. 당신이 쉼표를 제외 할 경우

예를 들어 (,) 다음 .replace 추가 (/,/g을, '>')는