ext
ExtJs3.2EditorGirdPanel增加一行和删除一行
http://blog.csdn.net/woshisap/article/details/6957331
http://www.cnblogs.com/yage/archive/2009/10/30/1591785.html
http://www.cnblogs.com/jianglan/archive/2011/07/28/2119101.html
<%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%>
<%
Stringpath=request.getContextPath();
StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
<html>
<head>
<basehref="<%=basePath%>">
<title>gridPanel</title>
<metahttp-equiv="pragma"content="no-cache">
<metahttp-equiv="cache-control"content="no-cache">
<metahttp-equiv="expires"content="0">
<metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
<metahttp-equiv="description"content="Thisismypage">
<linkrel="stylesheet"type="text/css"href="ext3.2/resources/css/ext-all.css"></link>
<scripttype="text/javascript"src="ext3.2/adapter/ext/ext-base.js"></script>
<scripttype="text/javascript"src="ext3.2/ext-all.js"></script>
<scripttype="text/javascript"src="ext3.2/src/local/ext-lang-zh_CN.js"></script>
<scripttype="text/javascript">
Ext.onReady(function(){
varcum=newExt.grid.ColumnModel([{
header:'类型ID',
dataIndex:'sortId',
editor:newExt.grid.GridEditor(
newExt.form.TextField({
allowBlank:false
})),
},{
header:'类型姓名',
dataIndex:'sortName',
editor:newExt.grid.GridEditor(
newExt.form.TextField({
allowBlank:false
}))
},{
header:'父类型',
dataIndex:'parentSort',
editor:newExt.grid.GridEditor(
newExt.form.TextField({
allowBlank:false
}))
},{
header:'类型描述',
dataIndex:'sortDescn',
editor:newExt.grid.GridEditor(
newExt.form.TextField({
allowBlank:false
}))
},{
header:'日期',
dataIndex:'kdtime',
editor:newExt.grid.GridEditor(
newExt.form.TextField({
allowBlank:false
}))
}]);
varcumdata=[
['1','String','Object','字符串类型','2010-05-22'],
['2','Integer','Object','整数类型','2010-06-07'],
['3','GridView','Observable','用户界面的封装','2010-05-05'],
['4','ColumnModel','Observable','Grid列模型的默认实现','2001-07-05'],
['5','EditorGridPanel','GridPanel','用于在指定某些的列可以编辑单元格','2007-06-01'],
['6','PropertyRecord','Object','用于表示一对"名称/值"的数据','2009-09-03']
];
varstore=newExt.data.Store({
proxy:newExt.data.MemoryProxy(cumdata),
reader:newExt.data.ArrayReader({},[
{name:'sortId'},
{name:'sortName'},
{name:'parentSort'},
{name:'sortDescn'},
{name:'kdtime'}
])
});
varp=newExt.data.Record({
sortId:'',
sortName:'',
parentSort:'',
sortDescn:'',
kdtime:''
});
store.load();
varcumgrid=newExt.grid.EditorGridPanel({
renderTo:'cumGrid',
store:store,
stripeRows:true,
viewConfig:{
forceFit:true,
scrollOffset:30,
sortAscText:'升序',
sortDescText:'降序'
},
height:200,
width:500,
colModel:cum,
tbar:newExt.Toolbar(['-',{
text:'添加一行',
handler:function(){
cumgrid.stopEditing();
store.insert(0,p);
cumgrid.startEditing(0,0);//激活该行的编辑状态
}
},'-',{
text:'删除一行',
handler:function(){
Ext.Msg.confirm('信息','确定要删除',function(btn){
if(btn=='yes'){
varsm=cumgrid.getSelectionModel();//得到表格的选择模型
varcell=sm.getSelectedCell();//通过选择模型得到选择的单元格
varrecord=store.getAt(cell[0]);//得到store对应的Record
store.remove(record);
}
})
}
}])
});
});
</script>
</head>
<body>
<divid="cumGrid"></div>
</body>
</html>