Server端:
import com.opensymphony.xwork2.ActionSupport;
import org.springside.modules.web.struts2.Struts2Utils;public class Action extends ActionSupport {
public void query(){
String json = "从后台拼好的json";
Struts2Utils.renderText(json);
}
}客户端:
Ext.namespace('Test');
Test.reader = new Ext.data.JsonReader({
root : 'records',
totalProperty : 'totalRecords'
}, [{
name : 'id',
type : 'string'
},
....
]);Test.cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
new Ext.grid.CheckboxSelectionModel(), {
header : '序号',
dataIndex : 'id',
sortable : true,
width : 100,
align : 'center',
hidden:true
},
....
]
);Test.pageToolbar = new Ext.PagingToolbar({
pageSize : 10,
displayInfo : true,
store : Test.workChangeStore,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录!"
});Test.workChangeStore = new Ext.data.GroupingStore({
autoLoad : false,
proxy : new Ext.data.HttpProxy({
method : 'POST',
url : 'action!query.action'
}),
reader : Test.reader
});/**
* 创建Grid
*/
Test.grid = new Ext.grid.GridPanel({
region : 'center',
store : Test.workChangeStore,
stripeRows : true,
anchor:'100%',
frame:true,
sm : new Ext.grid.CheckboxSelectionModel(),
cm : Test.cm,
tbar : Test.toolBar,
bbar : Test.pageToolbar,
stripeRows : true,
viewConfig:{
columnsText:"显示/隐藏列",
sortAscText:"正序排列",
sortDescText:"倒序排列",
forceFit : true
}
});
import com.opensymphony.xwork2.ActionSupport;
import org.springside.modules.web.struts2.Struts2Utils;public class Action extends ActionSupport {
public void query(){
String json = "从后台拼好的json";
Struts2Utils.renderText(json);
}
}客户端:
Ext.namespace('Test');
Test.reader = new Ext.data.JsonReader({
root : 'records',
totalProperty : 'totalRecords'
}, [{
name : 'id',
type : 'string'
},
....
]);Test.cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
new Ext.grid.CheckboxSelectionModel(), {
header : '序号',
dataIndex : 'id',
sortable : true,
width : 100,
align : 'center',
hidden:true
},
....
]
);Test.pageToolbar = new Ext.PagingToolbar({
pageSize : 10,
displayInfo : true,
store : Test.workChangeStore,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录!"
});Test.workChangeStore = new Ext.data.GroupingStore({
autoLoad : false,
proxy : new Ext.data.HttpProxy({
method : 'POST',
url : 'action!query.action'
}),
reader : Test.reader
});/**
* 创建Grid
*/
Test.grid = new Ext.grid.GridPanel({
region : 'center',
store : Test.workChangeStore,
stripeRows : true,
anchor:'100%',
frame:true,
sm : new Ext.grid.CheckboxSelectionModel(),
cm : Test.cm,
tbar : Test.toolBar,
bbar : Test.pageToolbar,
stripeRows : true,
viewConfig:{
columnsText:"显示/隐藏列",
sortAscText:"正序排列",
sortDescText:"倒序排列",
forceFit : true
}
});
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货