87,920
社区成员
发帖
与我相关
我的任务
分享
xtype: 'gridcolumn',
width: 50,
dataIndex: 'mark',
text: 'Mark',
editor: {
xtype: 'textfield',
enableKeyEvents: true
}
这一句,也能实现列的编辑问题。
不过版主知道怎么在下面添加的保存按钮中添加保存的代码?
组长写的是var store=Ext.getCmp('gridZhuguan').store;
还要添加updataData()代码么?
var rolecols = [{
width:25,
renderer:function(value)
{
return '<img src= ././image/role.png />';
}
},{
text:'角色编号',
dataIndex:'rolecode',
width:100
},{
text:'角色名称',
dataIndex:'rolename',
editor:{xtype:'textfield',allowBlank:false},
width:200
},{
text:'描述',
dataIndex:'describe',
editor:{xtype:'textfield'},
flex:1
}];
gridpanel中设置列为上面的变量
var gridrole = Ext.create('RoleGrid',{
id:'gridrole',
columns:rolecols,
tbar:rolebar,
border:false,
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})]
});
{
text:'保存',
iconCls:'saveicon',
handler:function(){
gridrolestore.sync({
success:function(optional){
Ext.MessageBox.alert('提示','保存成功');
}
});
}
},
我用的是批量提交的方法,调用store的sync方法,它会将所有修改的记录组织成json传递到后台
下面是store的定义,里面定义了api
var gridrolestore = Ext.create('Ext.data.Store',{
model:Role_Model,
proxy:{
type:'ajax',
// url:'././RoleServlet',
api:{
read:'././RoleServlet',
create:'././RoleServlet?optype='+OPERATION_NEW,
update:'././RoleServlet?optype='+OPERATION_EDIT,
destroy:'././RoleServlet?optype='+OPERATION_DEL
},
reader:{
type:'json',
root:'items',
idProperty:'rolecode',
messageProperty:'msg'
},
writer:{
type:'json',
writeAllFields:false,
root:'data',
allowSingle:false
}
}
});
xtype: 'gridcolumn',
width: 50,
dataIndex: 'mark',
text: 'Mark',
editor: {
xtype: 'textfield',
enableKeyEvents: true
}
这一句,也能实现列的编辑问题。
不过版主知道怎么在下面添加的保存按钮中添加保存的代码?
组长写的是var store=Ext.getCmp('gridZhuguan').store;
还要添加updataData()代码么?
[/quote]
刚用Ext做完一个工程,也是操纵大量ChineseTable的 。
回到问题。”“” 不过版主知道怎么在下面添加的保存按钮中添加保存的代码?“”“
简单说下我理解的store
你从后台取得的数据,应该是先配置到store里面,然后再将store配置到grid里面。(注意columns和fields的对应,col应该是fields的子集。)
这时候你在前台做的任何编辑表格的东西,都不回对store造成实质的数据变化。因为每一条record都有一个raw数值,来保存原来的数据。
这时候:::
1、你如果只是想暂时的保存在客户端,可以使用sync方法,就可以将数据同步到前台也就是单元格的左上角的小红点消失了。
2、如果想保存到客户端,就从store里取数据,发送到server保存,然后回显到前台,也能实现同步。
可能一些名词或想法解释有错。 具体的可以查下DOCS。
祝好!