52,797
社区成员
发帖
与我相关
我的任务
分享
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="extjs/adapter/ext/ext-base.js"> </script>
<script type="text/javascript" src="extjs/ext-all.js"> </script>
<script type="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();
num=1;
var data=[
['1','2','3','4']
];
js=new Ext.data.Store({
proxy:new Ext.data.MemoryProxy(data),
reader:new Ext.data.ArrayReader({},["cnum","cxing","cchang","ckuan"])
});
js.load();
var colM=new Ext.grid.ColumnModel([{
header:"车号",
width:200,
dataIndex:"cnum",
editor:new Ext.grid.GridEditor(new Ext.form.TextField({allowBlanlk:false}))},
{header:"车型",
width:120,
dataIndex:"cxing",
editor:new Ext.grid.GridEditor(new Ext.form.TextField({allowBlanlk:false}))
},
{header:"车长",
dataIndex:"cchang",
width:120,
editor:new Ext.grid.GridEditor(new Ext.form.TextField({allowBlanlk:false}))},
{header:"车宽",
dataIndex:"ckuan",
width:120,
editor:new Ext.grid.GridEditor(new Ext.form.TextField({allowBlanlk:false}))}
])
record=Ext.data.Record.create([
{name:'cnum'}
,
{name:'cxing'}
,
{name:'cchang'}
,
{name:'ckuan'}
]);
var dgrid= new Ext.grid.EditorGridPanel({
autoEncode:true,
frame:true,
width:600,
height:300,
clicksToEdit:1,
tbar:[
{pressed:true,text:'添加',handler:function(){
var initValue = {cnum:'',cxing:'',cchang:'',ckuan:''};
var p = new record(
initValue
);
js.insert(num,p);
num=num+1;
p.dirty=true;
p.modified=initValue;
if(js.modified.indexOf(p)==-1){
js.modified.push(p);
}
}
},
{xtype:"tbseparator"},
{pressed:true,text:'删除',handler:function(){
//Ext.Msg.confirm('信息','确定要删除?',
if(num==1){Ext.MessageBox.show({title:'系统提示',msg:'已经没有可供删除的记录!'})}
else {js.remove(js.getAt(num-1));num=num-1;}
}
},
{pressed:true,text:'刷新',handler:function(){ Ext.getCmp('grid').getGrid.store=js;
}}
],
cm:colM,
store : js,
//width:300,
//heigth:200,
autoShow:true,
renderTo:'grid'
})
})
</script>
<div id="grid"> </div>