json数据:{"counts":1,"surveys":[{"count":0,"createTime":null,"deadline":null,"des":null,"grade":false,"id":1,"name":"关于JSP科恒调查","open":false,"password":null,"publishTime":null,"surveyType":{"id":1,"name":"教学反馈调查类"}}]}
数据我就不贴那么多啦
model:[code="java"]Ext.define('MyExtJS.model.MenuModel', {
extend : 'Ext.data.Model',
fields : [{
name : 'id',
mapping : 'id'
}
, 'name', 'isOpen', 'count',
{
name : 'type',
mapping : 'surveyType.name'
},{
name : 'createTime',
mapping : 'createTime',
type : 'date',
dateFormat : 'timestamp'
}, {
name : 'publishTime',
mapping : 'publishTime',
type : 'date',
dateFormat : 'timestamp'
}, 'password', 'isGrade']
});[/code]
store:[code="java"]Ext.define('MyExtJS.store.SurveyStore', {
extend : 'Ext.data.Store',
model : 'MyExtJS.model.SurveyModel',
autoLoad : true,
proxy : {
type : 'ajax',
url:'menu/survey!quryAllSurvey',
reader : {
root : 'surveys',
type: 'json',
totalProperty : 'counts'
},
// sends single sort as multi parameter
simpleSortMode : true
},
sorters : [{
property : 'id',
direction : 'ASC'
}]
})
[/code]
view:[code="java"]Ext.define('MyExtJS.view.SurveyList', {
extend : 'Ext.grid.Panel',
alias : 'widget.surveylist',
title : '问卷列表',
store : 'SurveyStore',
selType : 'cellmodel', // 设置为单元格选择模式Ext.selection.CellModel
tbar : [{
text : '取得所选单元格',
handler : function() {
var cell = grid.getSelectionModel()
.getCurrentPosition();
alert(Ext.JSON.encode(cell));
}
}],
initComponent : function() {
this.columns = [{
id : 'surveys',
text : "id",
dataIndex : 'id', // 与Model对应
// flex : 1,
// renderer: renderTopic,
sortable : false
}, {
text : "名称",
dataIndex : 'name',
flex : 1,
// hidden: true,
sortable : true
}, {
text : "是否开放",
dataIndex : 'isOpen',
xtype : 'booleancolumn',
trueText : '是',
falseText : '否',
// width: 70,
// align: 'right',
sortable : true
}, {
// id: 'last',
text : "问卷类型",
dataIndex : 'type',
// width: 150,
// renderer: renderLast,
sortable : true
}, {
text : "问卷限制数量",
dataIndex : 'count',
// width: 70,
// align: 'right',
sortable : true
}, {
text : "创建时间",
dataIndex : 'createTime',
xtype : 'datecolumn',
format : 'Y-m-d h:m:s',
// width: 70,
// align: 'right',
sortable : true
}, {
text : "发布时间",
dataIndex : 'publishTime',
xtype : 'datecolumn',
format : 'Y-m-d h:m:s',
// width: 70,
// align: 'right',
sortable : true
}, {
text : "密码",
dataIndex : 'password',
// width: 70,
// align: 'right',
sortable : true
}, {
text : "是否是打分问卷",
dataIndex : 'isGrade',
xtype : 'booleancolumn',
trueText : '是',
falseText : '否',
// width: 70,
// align: 'right',
sortable : true
}];
this.callParent(arguments);
}
});[/code]