ext 动态删除行的问题
Ext.onReady(function() {
var store= Ext.create('Ext.data.Store', {
fields: ['id', 'username', 'password'],
proxy: {
type: 'ajax',
url:'userlogin!list.action',
reader: {
type: 'json',
root: 'users'
}
},
autoLoad:true
});
var productPanel = new Ext.Panel({
title : ' 模块 1 ',
//layout : 'fit',
id:'productPanel',
bbar : [{
text : '添加',
iconCls : 'add',
handler :showAddBook
}, {
text : '删除',
iconCls : 'remove'
handler :removeUser 在这边家一个function实现点击某一行在按删除 实现删除功能
}, {
text : '修改',
iconCls : 'option'
}
],
defaults : {
// applied to each contained panel
bodyStyle : 'padding:0px'
},
layout: {
type: 'accordion',
animate: true
},
items : [{
title : '参数配置',
xtype: 'grid',
columns: [
{ text: 'Id', dataIndex: 'id' },
{ text: 'Username', dataIndex: 'username', flex: 1 },
{ text: 'Password', dataIndex: 'password' }
]
,store:store
},{
title : '参数配置',
html : '<P align="center"><a href="http://www.baidu.com" target="ifrMID">想看百度就点我</a></p>'
},
{
title : '参数配置',
html : '<p>这是参数配置</p>'
}]
});
var systemconfPanel= new Ext.Panel({
title : ' 模块2 ',
//layout : 'fit',
id:'systemconfPanel',
defaults : {
// applied to each contained panel
bodyStyle : 'padding:0px'
},
layout: {
type: 'accordion',
animate: true
},
items : [{
title : '系统初始化',
html : '<p>这是系统初始化</p>'
}, {
title : '参数配置',
html : '<p>这是参数配置</p>'
}, {
title : '知识管理',
html : '<p>这是知识管理</p>'
}]
});
var viewport = new Ext.Viewport({
layout : 'border',
renderTo : Ext.getBody(),
items : [//viewport的ITEM开始
//北方
{
title : '<marquee width="400px">This is ext</marquee>',
id : "north",
region : 'north',
xtype : 'panel',
spilt : true,
height : 120,
html : '<p>GPS导航业务</p>',
bbar : [{
iconCls : 'add',
text : '管理员'
}, '-', {
text : Ext.Date.format(new Date(), 'Y年m月d日 a g:i ')
}, '->', {
text : '退出',
iconCls : 'remove',
handler : exit
}],
bodyStyle : 'backgroud-color:#99bbe8;line-height : 50px;padding-left:20px;' +
'font-size:22px;color:#000000;font-family:黑体;font-weight:bolder;'+
'background: -webkit-gradient(linear, left top, left bottom, ' +
'color-stop(0%, rgba(153,187, 232, 0.4) ),' +
'color-stop(50%, rgba(153, 187, 232, 0.8) ),' +
'color-stop(0%, rgba(153, 187, 232, 0.4) ) );'
},
//西方
{
title : '菜单',
region : 'west',
iconCls : 'option',
id : 'west', // see Ext.getCmp() below
width: 280, // give east and west regions a width
minSize: 175,
maxSize: 400,
margins: '0 0 0 0',
collapsible: true,
split: true,
layout: 'fit', // specify layout manager for items
items: // 西部的ITEM开始 // this TabPanel is wrapped by another Panel so the title will be applied
new Ext.TabPanel({
activeTab : 0,
width : 200,
defaults : {
autoScroll : true
},
items :
[productPanel,
systemconfPanel
]
})//tabPanel结束
//西部ITEM的结束
},
//中间
{
title : '中间',
region : 'center',
xtype : 'panel',
html: '<iframe frameborder="0" marginheight="0" width="100%" height="100%" marginwidth="0" scrolling="auto" name="ifrMID"></iframe>',
spilt : true
}]
//viewport的ITEM结束
});
var bookForm = new Ext.FormPanel({
labelSeparator: ":",
frame:true,
border:false,
items:[
{
xtype:'hidden',
name:'id'
},{
xtype:'textfield', //文本区
width:220,
allowBlank:false,
blankText:'用户名不能为空',
name:'user.username',
fieldLabel:'用户名 '
},{
xtype:'textfield',
width:220,
allowBlank:false,
blankText:'密码不能为空',
name:'user.password',
fieldLabel:'密码'
}
],
buttons:[
{
text:'关闭',
handler:function(){
win.hide();
}
},{
text:'提交',
handler:function(){
if(bookForm.getForm().isValid()) {
Ext.MessageBox.show({
title:'请等待',
msg:'正在加载',
progressText:'',
width:300,
progress:true,
closable:'false',
animEl:'loding'
});
var f = function(v){
return function(){
var i=v/11;
Ext.MessageBox.updateProgress(i,'');
}
}
for(var i=1;i<33;i++){
setTimeout(f(i),i*1500);
}
//提交到服务器操作
bookForm.form.doAction('submit',{
url:'userlogin!add.action',
method:'post',
success:function(form,action){
Ext.Msg.alert("添加成功!");
win.hide();
store.reload()
},
failure:function(form,action){
Ext.Msg.alert("添加失败!",action.result.message);
}
});
}
}
}
]
});
var win = new Ext.Window({ //创建弹出窗口
layout:'fit',
width:250,
closeAction:'hide',
height:200,
resizable:false,
shadow:true,
modal:true,
closable:true,
bodyStyle:'padding:5 5 5 5',
animCollapse:true,
items:[bookForm]
});
function showAddBook(){
bookForm.form.reset();
bookForm.isAdd = true;
win.setTitle('新增用户');
win.show();
}
function exit(){
document.location="login.jsp";
}
function removeUser(){
我的想法是弹出一个框 问确定删除吗 点击确定的时候 执行后台的action传来的方法 ~ (方法已写好~)想象添加用户那样 没头绪 不知道怎么写 请大大告知 小弟菜鸟~
}
});