Work used to ExtJS, from the background to obtain data, the use of ExtJS own Ext.data.store method, and then encapsulated the Extgridreturn method,
Purpose: The foreground uses the Ext.data.store to read from the backstage data, the background encapsulates the Extgridreturn type.
The front desk is as follows:
This.store = new Ext.data.Store ({
Remotesort:true,
baseparams:{
start:0,
Limit:this.pageSize
},
Proxy:new Ext.data.HttpProxy ({
Method: ' POST ',
Url:this.getAllUrl
}),
Reader:new Ext.data.JsonReader ({
Totalproperty: ' Results ',
Root: ' Rows '
},[' Rulesid ', ' rulestitle ', ' rulescontent ', ' rulestype ', ' UpdateUser ', {
Name: ' UpdateTime ',
Type: ' Date ',
DateFormat: ' Time '
}, ' Rulesauthor ', ' istop ', {
Name: ' Createtime ',
Type: ' Date ',
DateFormat: ' Time '
}])
});
The current data reader is rooted and totalproperty, so the type of background encapsulation is as follows:
Package cn.edu.hbcf.common.vo;
Import java.util.List;
/**
* EXT Grid return Object
*
* @author Lipenghui
*
*/
public class Extgridreturn {
/**
* Record the total number of bars
*/
private int results;
private int othercount;
/**
* All data
*/
Private list<?> rows;
Public Extgridreturn () {
}
public Extgridreturn (int results, list<?> rows) {
This.results = results;
This.rows = rows;
}
public int GetResults () {
return results;
}
public void SetResults (int results) {
This.results = results;
}
Public list<?> getRows () {
return rows;
}
public void Setrows (list<?> rows) {
This.rows = rows;
}
public int Getothercount () {
return othercount;
}
public void Setothercount (int othercount) {
This.othercount = Othercount;
}
}
The method in the controller can be written as follows:
@RequestMapping (value= "/selectbaserules", Method=requestmethod.post)
@ResponseBody
Public Object selectbaserules (Extpager pager,int rulestype) {
criteria = new criteria ();
if (Pager.getstart ()!=null &&pager.getlimit ()!=null) {
Criteria.setstart (Pager.getstart ());
Criteria.setlimit (Pager.getlimit ());
Criteria.setoraclestart (Pager.getstart ());
Criteria.setoracleend (Pager.getstart () + pager.getlimit ());
}
try {
Criteria.put ("Rulestype", Rulestype);
list<baserules> list = Baserulesservice.selectbaserules (criteria);
int total= baserulesservice.gettotalcount ();
return new Extgridreturn (total, list);
} catch (Exception e) {
E.printstacktrace ();
return new Exceptionreturn (e);
}
},
The XML configuration file in MyBatis is as follows:
<select id= "Selectbaserules" resultmap= "Baserulesmap" parametertype= "Criteria" >
<include refid= "Common. Oracle_pagination_head "/>
Select t.rules_id Rulesid,
T.rules_title Rulestitle,
T.rules_content Rulescontent,
T.rules_type Rulestype,
T.update_time UpdateTime,
T.rules_author Rulesauthor,
T.is_top Istop,
T.create_time Createtime,
T.update_user UpdateUser,
S.account account,
S.real_name Realname,
s.user_id userId
From Sms_base_rules t
Left JOIN Spauth.base_users S
On s.user_id = T.update_user
<where>
T.rules_type=#{condition.rulestype,jdbctype=integer}
</where>
<include refid= "Common. Oracle_pagination_tail "/>
</select>
It is very simple to encapsulate the type of ExtJS read.
ExtJS data reader Store and background return type simple parsing