Ext.onReady(function(){
Ext.QuickTips.init();
var fm = Ext.form;
var sm = new Ext.grid.CheckboxSelectionModel({handleMouseDown: Ext.emptyFn});<!--设置列首是否为复选样式-->
var cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer()<!--列首是否为行的索引-->
,{
header:'编号',<!--列名-->
dataIndex:'id',<!--对应数据的属性名-->
width:60
},{
header: "书名",
dataIndex: 'title',
editor: new fm.TextField({
allowBlank: false
}),
width:100
},{
header: "作者",
dataIndex: 'author',
editor: new fm.TextField({
allowBlank: false
}),
width:100
}
]);
<!--设置默认的排序开启-->
cm.defaultSortable = true;
var store =new Ext.data.JsonStore({
<!--指明连接的strutsAction的路径-->
url: 'books.do',
<!--指明数据存放的位置-->
root: 'members',
<!--指明列名对应的数据列名-->
fields: ['id','title','author']
});
<!--加载数据-->
store.load();
<!--构建编辑表-->
var g=new Ext.grid.EditorGridPanel({
cm:cm,
<!--对层进行重画-->
renderTo:"member_grid",
<!--指明数据集-->
store:store,
<!--自适应表格的高度-->
<!--autoHeight:true,-->
autoSizeColumns :true,
width:300,
height:150,
<!--产生滚动条-->
collapsible: true,
animCollapse: false,
enableDragDrop :true,
sm:sm,<!--是否单选或者多选-->
<!--工具栏-->
tbar:[{
text:'添加',
tooltip:'添加',
iconCls:'add'
},'-',
{
text:'修改',
tooltip:'修改',
iconCls:'option'
}
]
});
});