Code:
var proxybbp = new Ext.data.HttpProxy({
method: 'POST',
api: {
read : '../load-edit.php?ac=9',
create : '../save-form.php?ac=21.1&st=b',
update: '../save-form.php?ac=21.1&upd=y',
destroy: '../save-form.php?ac=21.1&del=y'
}
});
var readerbbp = new Ext.data.JsonReader({
totalProperty: 'total',
successProperty: 'success',
idProperty: 'id',
pruneModifiedRecords :true,
root: 'results',
messageProperty: 'message' // <-- New "messageProperty" meta-data
}, [
{name: 'itemcode', allowBlank: true},
{name: 'itemdesc', allowBlank: true},{name: 'uom', allowBlank: true},
{name: 'reqqty', allowBlank: true} , {name: 'issqty', allowBlank: true} ,
{name: 'xkg', allowBlank: true} ,{name: 'totxkg', allowBlank: true}
]);
// The new DataWriter component.
var writerbbp = new Ext.data.JsonWriter({
encode: true,
writeAllFields: true
});
var storebbp = new Ext.data.Store({
id: 'user',
proxy: proxybbp,
reader: readerbbp,
writer: writerbbp, // <-- plug a DataWriter into the store just as you would a Reader
autoSave: false, // <-- false would delay executing create, update, destroy requests until specifically told to do so with some [save] buton.,
remoteSort:false,
batch :true
});
var qtybox = new fm.NumberField({ width:100, allowBlank: true});
var cmbbp = new Ext.grid.ColumnModel({
// specify any defaults for each column
defaults: {
sortable: true // columns are not sortable by default
},
columns: [
{ header: 'Item Code', dataIndex: 'itemcode', width: 150 } ,
{ header: 'Item Name', dataIndex: 'itemdesc', width:180 } ,
{ header: 'UOM', dataIndex: 'uom', width:100 } ,
{ header: 'Indent Qty', dataIndex: 'reqqty', width:100 },
{ header: 'Issue Qty', dataIndex: 'issqty', width:100 , editor:qtybox},
{ header: 'Per Unit Kgs', dataIndex: 'xkg', width:100 },
{ header: 'Total Kgs', dataIndex: 'totxkg', width:100} ]
});
var gridbbp = new Ext.grid.EditorGridPanel({
store: storebbp, stripeRows: true,selModel: new Ext.grid.RowSelectionModel(),
cm: cmbbp,
width: 650,
height: 200,
autoSave: false, frame: false,
clicksToEdit: 1,
tbar: [ <?php if(0==1) { ?>{
text: 'Add Row',iconCls: 'silk-add',scope: this,
handler : function(){
// access the Record constructor through the grid's store
var Part = gridbbp.getStore().recordType;
var p = new Part({
itemcode:'',itemdesc:'',uom:'',issqty:'0.00',xkg:'0.00',totxkg:'0.00'
});
gridbbp.stopEditing();
storebbp.insert(0, p);
//gridbbp.startEditing(0, 0);
}
},'-',<? } if(01==1) { ?> {
text: 'Delete Row',
iconCls: 'silk-delete',
handler: function() {
var index = gridbbp.getSelectionModel().getSelections();
if (!index) {
return false;
}
var rec = storebbp.getAt(index);
storebbp.remove(index);
},
scope: this
}, '-' <?php } ?>]
});
The above one is the code for editorgridpanel. While clicking the save button i am posting the data using following code
Code:
buttons: [{
text: 'Save',
handler: function () {
// when this button clicked, sumbit this form
simple.getForm().submit({
waitMsg: 'Saving...', // Wait Message
success: function (form, action) { // When saving data success
if(action.result.success=="true") {
storebbp.baseParams = { fgissno: action.result.fgissno};
var t= storebbp.save({ callback: function(rec, options, success){
var jsonData = readerbbp.jsonData;
console.dir(jsonData);
}
});
//alert(t);
storebbp.commitChanges();
Ext.MessageBox.alert ('Message','Data Added successfully');
// clear the form
simple.getForm().reset(); storebbp.removeAll();
grid.getStore().reload();
} else { Ext.MessageBox.alert ('Message','Data Addition Failed \n '+action.result.msg); }
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Message','Saving data failed! ');
}
});
}
},{
text: 'Cancel',
handler: function () {
// when this button clicked, reset this form
simple.getForm().reset(); storebbp.removeAll();
}
}]
While i click the save button the formpanel posting the data correctly. but the gridpanel URL is getting connection abort in firebug. even its not hidding the save-form.php page.