1 store中设置 remoteSort:true, //用服务端的排序规则
2 String sort = request.getParameter("sort");//排序字段 因为ext会根据点击列自动传递sort参数,
3 处理 sort数据 //获取排序字段和排序方式
JSONArray jsonArray = null;
jsonArray = new JSONArray(sort);
String property = (String) jsonArray.getJSONObject(0).get("property");//排序字段
String direction = (String) jsonArray.getJSONObject(0).get("direction");//排序方式 ASC/DESC
4 处理property
//需要的排序字段的判断
if("createDate".equals(property)) {
property = "create_date";
}else if("updateDate".equals(property)) {
property = "update_date";
}else {
property=null;
}
4 sql的xml中 ,
<if test="direction!= null and '' !=direction and property!= null and '' !=property">
order by c.${property} ${direction}
</if>
2 String sort = request.getParameter("sort");//排序字段 因为ext会根据点击列自动传递sort参数,
3 处理 sort数据 //获取排序字段和排序方式
JSONArray jsonArray = null;
jsonArray = new JSONArray(sort);
String property = (String) jsonArray.getJSONObject(0).get("property");//排序字段
String direction = (String) jsonArray.getJSONObject(0).get("direction");//排序方式 ASC/DESC
4 处理property
//需要的排序字段的判断
if("createDate".equals(property)) {
property = "create_date";
}else if("updateDate".equals(property)) {
property = "update_date";
}else {
property=null;
}
4 sql的xml中 ,
<if test="direction!= null and '' !=direction and property!= null and '' !=property">
order by c.${property} ${direction}
</if>