2012-11-06 5 views
3

일부 레코드가있는 jqGrid가 있고 여러 조건을 기반으로 레코드를 필터링하려고합니다. 예를 들어클라이언트 측에서 여러 조건으로 jqGrid 필터링

,이 세 개의 열, 이름, 나이와 도시이며, 나는 다음과 같은 조건 그리드 필터링하려면 :

Name = "Mark" and Age = 25 and City = 'NY' 

다음 코드를 미세

var grid = jQuery("#memberDetails"); 
var postdata = grid.jqGrid('getGridParam', 'postData'); 

var filterArray = new Array(); 
var filterConidtion; 

filterConidtion = new Object(); 
filterConidtion.field = "name"; 
filterConidtion.op = "eq"; 
filterConidtion.data = "Mark"; 
filterArray.push(filterConidtion); 

filterConidtion = new Object(); 
filterConidtion.field = "Age"; 
filterConidtion.op = "eq"; 
filterConidtion.data = "25"; 
filterArray.push(filterConidtion); 

filterConidtion = new Object(); 
filterConidtion.field = "City"; 
filterConidtion.op = "eq"; 
filterConidtion.data = "NY"; 
filterArray.push(filterConidtion); 

jQuery.extend(postdata, { 
     filters: { 
      "groupOp": "and", 
      "rules": filterArray 
     } 
    }); 

grid.jqGrid('setGridParam', { 
      search: true, 
      postData: postdata 
    }); 

grid.trigger("reloadGrid", [{ 
     page: 1 
    }]); 

작동을 다음 필터 작동 방법을 잘 모르겠습니다.

Name = "Mark" and Age = 25 and (City = 'NY' OR City = 'FL') 

groupOp ork 또는 AND 조건에서 orks 중 어느 하나에 하위 조건을 포함시키는 방법이 확실하지 않은 경우 groupOp

감사합니다.

답변

5

filters의 형식은 the documentation에 설명되어 있습니다. 좀 더 복잡한 검색 기준을 구현하기 위해 속성 인 filters을 사용할 수 있습니다. 해당 코드는 다음과 같을 수 있습니다.

관련 문제