jqGrid Data - Search (configuration)

jqGrid v4.6

by 1004lucifer

HTML

<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/css/ui.jqgrid.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/js/i18n/grid.locale-kr.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqgrid/4.6.0/js/jquery.jqGrid.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.css">
<div style="height:350px;">
  <table id="list"><tr><td></td></tr></table> 
  <div id="pager"></div><br />
  <h4>
  크롬 개발자도구 켠 후 검색조건 넣고 '찾기' 버튼 클릭하면 Request에 해당 조건이 서버로 'filters'라는 파라메터로 넘어가는 것을 볼 수 있다.
  </h4>
</div>

JavaScript

var serverJsonData = 
{
   'page':'1',
   'total': 2,
   'records':'13', 
   'rows':[ 
     {'id': '1', 'invdate': '20-01-03', 'name': '1004lucifer', 'amount': '100', 'tax': '12', 'total': '300', 'note': 'description'},
     {'id': '2', 'invdate': '20-01-03', 'name': '1004lucifer', 'amount': '100', 'tax': '12', 'total': '300', 'note': 'description'},
     {'id': '3', 'invdate': '20-01-03', 'name': '1004lucifer', 'amount': '100', 'tax': '12', 'total': '300', 'note': 'description'},
     {'id': '4', 'invdate': '20-01-03', 'name': '1004lucifer', 'amount': '100', 'tax': '12', 'total': '300', 'note': 'description'},
     {'id': '5', 'invdate': '20-01-03', 'name': '1004lucifer', 'amount': '100', 'tax': '12', 'total': '300', 'note': 'description'},
     {'id': '6', 'invdate': '20-01-03', 'name': '1004lucifer', 'amount': '100', 'tax': '12', 'total': '300', 'note': 'description'}
    ] 
};

$("#list")
.jqGrid({
  url: '/echo/json/', // use JSFiddle echo service
  datatype: 'json',
  mtype: 'POST',
  postData: { json: JSON.stringify(serverJsonData) },
  colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
  colModel:[
    {name:'id',index:'id', width:65, searchoptions:{sopt:['eq','ne','lt','le','gt','ge']}},
    {name:'invdate',index:'invdate', width:90, searchoptions:{dataInit:function(el){$(el).datepicker({dateFormat:'yy-mm-dd'});} }},
    {name:'name',index:'name', width:100},
    {name:'amount',index:'amount', width:80, align:"right",searchoptions:{sopt:['eq','ne','lt','le','gt','ge']}},
    {name:'tax',index:'tax', width:80, align:"right", stype:'select', editoptions:{value:":All;0.00:0.00;12:12.00;20:20.00;40:40.00;60:60.00;120:120.00"}},
    {name:'total',index:'total', width:80,align:"right",searchoptions:{sopt:['eq','ne','lt','le','gt','ge']}},
    {name:'note',index:'note', width:150, sortable:false}		
  ],
  cellEdit: true,
  caption : 'JSON Data',
  height: 'auto',
  sortname: 'id',
  autowidth: true,
  rowNum: 5,
  pager:...