How does Jqgrid use its own search module for data query

When we use the integrated search box and click the find button, the page will send a request to the background:

http://localhost/GW/jcxxAction!ryxx_index_r.action?_search=true&nd=1523774629725&rows=5&page=1&sidx=&sord=asc&filters=%7B%22groupOp%22%3A%22OR%22%2C%22rules%22%3A%5B%7B%22field%22%3A%22job%22%2C%22op%22%3A%22cn%22%2C%22data%22%3A%22%E5%B7%A5%E7%A8%8B%22%7D%2C%7B%22field%22%3A%22trunname%22%2C%22op%22%3A%22eq%22%2C%22data%22%3A%225252%22%7D%5D%7D&searchField=&searchString=&searchOper=

This request mainly contains several pieces of information, several parameter information of paging query, such as: page, rows, sidx, sord. Another important parameter is the encrypted filters. This long string parameter contains all the conditions we want to query. How does the background receive it?

My project uses Struts2, define such a string variable with the same name as filters in the action, and give him set and get methods. In this way, the query condition information can be obtained in the action method.

System.out.println("Query condition:"+filters);

查询条件:{"groupOp":"AND","rules":[{"field":"job","op":"cn","data":"dsds"}]}

This is the data format of the query condition,

JSONObject jsonFilter = (JSONObject) JSONSerializer.toJSON( filters );  
    JSONArray rules = jsonFilter.getJSONArray("rules");  
    int rulesCount = JSONArray.getDimensions(rules)[0];  
    log.debug("Count Rules :" + rulesCount);  
for (int i = 0; i < rulesCount; i++) {  
    JSONObject rule = rules.getJSONObject(i);  
    log.debug("field :" + rule.getString("field"));  
    log.debug("op :" + rule.getString("op"));  
    log.debug("data :" + rule.getString("data"));  
}



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326480196&siteId=291194637