(function(){
Ext.QuickTips.init();
var grid = Ext.create('Ext.grid.Pale',{
title:'parentName',
frame:true,
forceFit:true,
width:890,
height:400
columns:[
{text:'name',dataIndex:'name'},
{text:'age',dataIndex:'age'},
{text:'mail',dataIndex:'mail',
field:[
xtype:'textfield',
allowBlank:false
]
}
],
tbar:[
{xtype:'button' text:'添加',iconcls:'table_add'},
{xtype:'button' text:'删除',iconcls:'table_remove'},
handler:function(o){
// var grid = o.findParentByType('gridpanel');//获得父类的panle
var grid = o.ownerCt.ownerCt;
var data = grid.getSelectionModel.getSelection();
if( data.length ==0){
Ext.Msg.alert('提示','至少选址一条数据');
}else{
var st = grid.getStore();//得到ID数据
var ids=[];
Ext.Array.each(data,function(records){
ids.push(records.get('name'));
})
Ext.Ajax.request({
url:'',
params:{ids:ids.join(',')},
method:'POST',
timeout:2000,
success: function(response,opts){
Ext.Array.each(data,function(records){
st.remove(records);
})
}
})
}
}
{xtype:'button' text:'修改',iconcls:'table_edit'},
{xtype:'button' text:'查看',iconcls:'table_comm'}
],
docketItems:[
xtype:'pagingtoolbar',
store:Ext.data.StoreManager.lookup('s_user'),
dock:'buttom',
displayInfo:true
],
plugins:[//添加单元格可编辑插件
Ext.create('Ext.grid.plugin.CellEditing',{
clicksToedit:1
});
],
setType:'checkboxmodel',//定义chekbox复选框
multiSelect:true,//允许多选
renderTo:'divId',
store:Ext.data.StoreManager.lookup('s_user')
});
});
})();
-----------------------------------------------------------------------------
Ext.define('user',{
extend:'Ext.data.Model',
fields:[
{name:'name',type:'string',sortable:true},
{name:'age',int:'string',sortable:true},
{name:'mail',type:'string',sortable:true}
]
});
Ext.create('Ext.data.Stroe',{
model:'user',
storeId:'s_user',
proxy :{
type:'ajax',
url:'testurl'
reader:{
type:'json',
root:'topis'//json 根节点 就是对象数组前节点名称
},
writer: {
type:'json'
}
},
autoLoad:true
});
Ext.QuickTips.init();
var grid = Ext.create('Ext.grid.Pale',{
title:'parentName',
frame:true,
forceFit:true,
width:890,
height:400
columns:[
{text:'name',dataIndex:'name'},
{text:'age',dataIndex:'age'},
{text:'mail',dataIndex:'mail',
field:[
xtype:'textfield',
allowBlank:false
]
}
],
tbar:[
{xtype:'button' text:'添加',iconcls:'table_add'},
{xtype:'button' text:'删除',iconcls:'table_remove'},
handler:function(o){
// var grid = o.findParentByType('gridpanel');//获得父类的panle
var grid = o.ownerCt.ownerCt;
var data = grid.getSelectionModel.getSelection();
if( data.length ==0){
Ext.Msg.alert('提示','至少选址一条数据');
}else{
var st = grid.getStore();//得到ID数据
var ids=[];
Ext.Array.each(data,function(records){
ids.push(records.get('name'));
})
Ext.Ajax.request({
url:'',
params:{ids:ids.join(',')},
method:'POST',
timeout:2000,
success: function(response,opts){
Ext.Array.each(data,function(records){
st.remove(records);
})
}
})
}
}
{xtype:'button' text:'修改',iconcls:'table_edit'},
{xtype:'button' text:'查看',iconcls:'table_comm'}
],
docketItems:[
xtype:'pagingtoolbar',
store:Ext.data.StoreManager.lookup('s_user'),
dock:'buttom',
displayInfo:true
],
plugins:[//添加单元格可编辑插件
Ext.create('Ext.grid.plugin.CellEditing',{
clicksToedit:1
});
],
setType:'checkboxmodel',//定义chekbox复选框
multiSelect:true,//允许多选
renderTo:'divId',
store:Ext.data.StoreManager.lookup('s_user')
});
});
})();
-----------------------------------------------------------------------------
Ext.define('user',{
extend:'Ext.data.Model',
fields:[
{name:'name',type:'string',sortable:true},
{name:'age',int:'string',sortable:true},
{name:'mail',type:'string',sortable:true}
]
});
Ext.create('Ext.data.Stroe',{
model:'user',
storeId:'s_user',
proxy :{
type:'ajax',
url:'testurl'
reader:{
type:'json',
root:'topis'//json 根节点 就是对象数组前节点名称
},
writer: {
type:'json'
}
},
autoLoad:true
});