reina8001
30 Jun 2008, 7:38 AM
How to reload grid after rowaction success?
Please see the following code:
Ext.BLANK_IMAGE_URL = 'http://'+myhost+'/extjs/resources/images/default/s.gif';
Ext.ns('myns');
myns.version = '1.0';
// create pre-configured grid class
myns.cpaGrid = Ext.extend(Ext.grid.GridPanel, {
width:728,
height:350,
border:true,
title:'CPA List',
initComponent:function() {
...
}); //end of this.action
this.action.on({
action:function(grid, record, action, row, col) {
if (action=='icon-join') {
var rec = grid.getSelectionModel().getSelected();
Ext.QuickTips.init();
if (rec.data['status']=='not join yet') {
var form_join = new Ext.form.FormPanel({
frame: true,
title: 'Join :'+rec.data['cid'],
bodyStyle: 'padding: 5px 5px 0',
width: 350,
labelWidth: 75,
defaults: {width: 230},
items: [{
.. }],
buttons: [{
text: 'Confirm',
type: 'submit',
handler: function() {
form_join.form.submit({
url: '../ajax_json.php?',
type: "POST",
success: function() {
Ext.MessageBox.alert('Message', +rec.data['cid']+' was joined successfully!);
//How to reload grid here?
},
failure: function() {
Ext.MessageBox.alert('Message', 'Join failed!');
Ext.getCmp('joinCampWindow').close();
}
});
}
}
}
} //end of action:function
}); //end of this.action.on
// configure the grid
Ext.apply(this, {
store:new Ext.data.GroupingStore({
reader:new Ext.data.JsonReader({
id:'cidst'
,totalProperty:'totals'
,root:'records'
,fields:[
{name: id}
.. ]
})
,proxy:new Ext.data.HttpProxy({url:'../../ajax_json.php?act=list',
type: "POST",
success: function() {
...
},
failure: function() {
Ext.MessageBox.alert('Message', 'Site: '+siteid+' is void.');
}})
//,groupField:'status'
,sortInfo:{field:'cid', direction:'ASC'}
}) // end of store
,columns:[
{header: "ID", width: 80, sortable: true, dataIndex: 'id'}
.. ,this.action
]
,plugins:[this.action]
,view: new Ext.grid.GroupingView({
forceFit:true
,groupTextTpl:'{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
})
,viewConfig: {
forceFit:true,
autoFill:true,
enableRowBody:true,
emptyText:'No Campaign has been created yet.'
}
}); // eo apply
// add paging toolbar
this.store.setDefaultSort('id', 'asc');
this.bbar = new Ext.PagingToolbar({
store:this.store
,displayInfo:true
,emptyMsg: 'No Campaign to display'
,emptyText:'No Campaign has been created yet.'
,id: 'login_statusbar'
,pageSize:30
});
// call parent
myns.cpaGrid.superclass.initComponent.apply(this, arguments);
} // eo function initComponent
,onRender:function() {
// call parent
myns.cpaGrid.superclass.onRender.apply(this, arguments);
this.store.load({params:{start:0, limit:30}});
} // eo function onRender
}); // eo extend
// register component
Ext.reg('cpaGrid', myns.cpaGrid);
// application entry point
Ext.onReady(function() {
var cpaApp = new myns.cpaGrid({
renderTo: 'cpa_div'
});
Please see the following code:
Ext.BLANK_IMAGE_URL = 'http://'+myhost+'/extjs/resources/images/default/s.gif';
Ext.ns('myns');
myns.version = '1.0';
// create pre-configured grid class
myns.cpaGrid = Ext.extend(Ext.grid.GridPanel, {
width:728,
height:350,
border:true,
title:'CPA List',
initComponent:function() {
...
}); //end of this.action
this.action.on({
action:function(grid, record, action, row, col) {
if (action=='icon-join') {
var rec = grid.getSelectionModel().getSelected();
Ext.QuickTips.init();
if (rec.data['status']=='not join yet') {
var form_join = new Ext.form.FormPanel({
frame: true,
title: 'Join :'+rec.data['cid'],
bodyStyle: 'padding: 5px 5px 0',
width: 350,
labelWidth: 75,
defaults: {width: 230},
items: [{
.. }],
buttons: [{
text: 'Confirm',
type: 'submit',
handler: function() {
form_join.form.submit({
url: '../ajax_json.php?',
type: "POST",
success: function() {
Ext.MessageBox.alert('Message', +rec.data['cid']+' was joined successfully!);
//How to reload grid here?
},
failure: function() {
Ext.MessageBox.alert('Message', 'Join failed!');
Ext.getCmp('joinCampWindow').close();
}
});
}
}
}
} //end of action:function
}); //end of this.action.on
// configure the grid
Ext.apply(this, {
store:new Ext.data.GroupingStore({
reader:new Ext.data.JsonReader({
id:'cidst'
,totalProperty:'totals'
,root:'records'
,fields:[
{name: id}
.. ]
})
,proxy:new Ext.data.HttpProxy({url:'../../ajax_json.php?act=list',
type: "POST",
success: function() {
...
},
failure: function() {
Ext.MessageBox.alert('Message', 'Site: '+siteid+' is void.');
}})
//,groupField:'status'
,sortInfo:{field:'cid', direction:'ASC'}
}) // end of store
,columns:[
{header: "ID", width: 80, sortable: true, dataIndex: 'id'}
.. ,this.action
]
,plugins:[this.action]
,view: new Ext.grid.GroupingView({
forceFit:true
,groupTextTpl:'{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
})
,viewConfig: {
forceFit:true,
autoFill:true,
enableRowBody:true,
emptyText:'No Campaign has been created yet.'
}
}); // eo apply
// add paging toolbar
this.store.setDefaultSort('id', 'asc');
this.bbar = new Ext.PagingToolbar({
store:this.store
,displayInfo:true
,emptyMsg: 'No Campaign to display'
,emptyText:'No Campaign has been created yet.'
,id: 'login_statusbar'
,pageSize:30
});
// call parent
myns.cpaGrid.superclass.initComponent.apply(this, arguments);
} // eo function initComponent
,onRender:function() {
// call parent
myns.cpaGrid.superclass.onRender.apply(this, arguments);
this.store.load({params:{start:0, limit:30}});
} // eo function onRender
}); // eo extend
// register component
Ext.reg('cpaGrid', myns.cpaGrid);
// application entry point
Ext.onReady(function() {
var cpaApp = new myns.cpaGrid({
renderTo: 'cpa_div'
});