首页 新闻 会员 周边

extjs 写了一个列表然后弹出框输出这一行的信息,感觉有点low,求大神给优化一下

0
[待解决问题]
var grid;
function doDelete(r) {
grid.store.removeAt(r);
}

function doUpdate(r) {
var record = grid.getStore().data.items[r].data;

var id = record.id;
var name = record.name;
var stuId = record.stuId;
var profession = record.profession;
var sex = record.sex;
var age = record.age;
var dealDate = record.dealDate;
var forml=Ext.create('Ext.form.Panel',{
width:500,
layout'anchor',
title:'更新学生',
items:[
{
fieldLabel:'学号:',
xtype:'textfield',
name:'stuId',
value: stuId,
anchor'95%',
id:'stuId'
},{
fieldLabel:'姓名:',
xtype:'textfield',
name:'name',
value: name,
anchor'95%',
id:'name'
},{
fieldLabel:'性别:',
xtype:'textfield',
name:'sex',
value: sex,
anchor'95%',
id:'sex'
},{
fieldLabel:'年龄:',
xtype:'textfield',
name:'age',
value: age,
anchor'95%',
id:'age'
},{
fieldLabel:'专业名称:',
xtype:'textfield',
name:'profession',
value: profession,
anchor'95%',
id:'profession'
}],
bbar: [{
xtype'tbfill'
},{
xtype'button',
text'保存',
disabledtrue,
formBindtrue,
handler: function() {
forml.getForm().submit({ success:function(form, action) {
alert(action.result.msg);
}, failure: function() { alert("失败") }
});
}
}, {
xtype: 'button',
text: '取消',
listeners: {
click: function () {
windowl.close();
}
}
},{
xtype:'tbfill'
}]
});
var windowl=Ext.create('Ext.window.Window', {
renderTo: Ext.getBody(),
headerfalse,
borderfalse, //没有边框  
resizablefalse, //不可以自由调整大小,默认可以  
width300,
items:[forml]
//Ext.getCmp('id').getValue();
});
windowl.show();
}

Ext.onReady(function() {



Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
{name: 'name', type: 'string'},
{name: 'stuId', type: 'string'},
{name: 'profession', type: 'string'},
{name: 'sex', type: 'string'},
{name: 'age', type: 'int'},
{name: 'dealDate', type: 'string'},
]
});

Ext.create('Ext.data.Store', {
storeId:'stStore',
model: 'User',
data:[{"id":42,"name":"颜朝华","stuId":"信息A031201","profession":"计算机科学与技术","sex":"","age":16,"dealDate":"2015-10-27"},
{"id":43,"name":"张霞","stuId":"信息A031202","profession":"计算机科学与技术","sex":"","age":16,"dealDate":"2015-10-27"},
{"id":44,"name":"贾宁","stuId":"信息A031203","profession":"计算机科学与技术","sex":"","age":16,"dealDate":"2015-10-27"},
{"id":45,"name":"郭鹏","stuId":"信息A031204","profession":"计算机科学与技术","sex":"","age":16,"dealDate":"2015-10-27"},
{"id":46,"name":"肖坚强","stuId":"信息A031205","profession":"计算机科学与技术","sex":"","age":16,"dealDate":"2015-10-27"},
{"id":47,"name":"李陶","stuId":"信息A031206","profession":"计算机科学与技术","sex":"","age":16,"dealDate":"2015-10-27"},
{"id":48,"name":"陈志军","stuId":"信息A031207","profession":"计算机科学与技术","sex":"","age":16,"dealDate":"2015-10-27"},
{"id":49,"name":"吴慧锋","stuId":"信息A031208","profession":"计算机科学与技术","sex":"","age":16,"dealDate":"2015-10-27"},
{"id":50,"name":"李文峰","stuId":"信息A031209","profession":"计算机科学与技术","sex":"","age":16,"dealDate":"2015-10-27"},
{"id":51,"name":"周雯","stuId":"信息A031210","profession":"计算机科学与技术","sex":"","age":16,"dealDate":"2015-10-27"}

]
});



grid = Ext.create('Ext.grid.Panel', {
title: '学生列表',
store: Ext.data.StoreManager.lookup('stStore'),
columns: [
{ text: 'id', dataIndex: 'id' },
{ text: '姓名', dataIndex: 'name'},
{ text: '学号', dataIndex: 'stuId' },
{ text: '专业', dataIndex: 'profession' },
{ text: '性别', dataIndex: 'sex' },
{ text: '年龄', dataIndex: 'age' },
{ text: '操作时间', dataIndex: 'dealDate' },
{ text: '操作', dataIndex: 'operation' ,

renderer : function(value, cellmeta, record, rowIndex,columnIndex,store) {

return '<span onclick="doDelete('+rowIndex+')"><a href="#">删除</a></span>&nbsp;<span onclick="doUpdate('+rowIndex+')"><a href="#">更新</a></span>';
}
}

],
renderTo: Ext.getBody()
});



});


WindNight的主页 WindNight | 菜鸟二级 | 园豆:202
提问于:2017-12-23 21:46
< >
分享
所有回答(1)
0

建议给代码加上高亮

dudu | 园豆:31003 (高人七级) | 2017-12-23 22:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册