PDA

View Full Version : Unable to store data using Ext.grid.EditorGridPanel



sriramkumarp
11 Apr 2012, 4:49 AM
Dear Experts,

I am not able to save data using Ext.grid.EditorGridPanel.

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

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.


Please help me to solve this is issue.

I am using Extjs 3.x
PHP 5.x
Apache 2
Postgres 9.x

scottmartin
11 Apr 2012, 5:26 PM
When you are sending data using submit, are you getting the callback you expect? I noticed you also have a
store.save() as well as the submit?

What is happening on the header / response for this action after the submit?

Regards,
Scott.

sriramkumarp
21 Apr 2012, 10:25 PM
Thank you very much for your reply Mr. Scott.
Here, I am saving the master records first. Once the master records get saved then i am saving the detail records by using the grid store.
When i checked the firebug console the store save url taking long time to get response. Finally its giving the abort status. So the detail records are not saving.
But When i try this same screen in Win 7 OS Client Its working properly. What could be the problem. Please help me out to fix this issue.

Thanks in advance.

Sriram P

scottmartin
23 Apr 2012, 2:26 PM
If you do not see any errors on your console, I would take a look at your server side and see why your data is not getting returned.

A timeout could also mean your process is taking too long. Have you verified that this is not the case?

Regards,
Scott.

sriramkumarp
23 Apr 2012, 9:22 PM
If you do not see any errors on your console, I would take a look at your server side and see why your data is not getting returned.

A timeout could also mean your process is taking too long. Have you verified that this is not the case?

Regards,
Scott.

First of all thank you very much Mr.Scott,

I had checked that thing also. I just created a php page, which has <?php echo "hello"; ?> only.
I am trying to call this page using dataStore proxy. This is also not sending reply.

But if i have only four records in my grid its getting the response from server. If its more than four then the request getting aborted. I have increased the PHP.ini Post data limit and Post array Limit.

If i use the Win7 OS in client machine, then there is no problem. Other than win7 OS like win xp, Ubuntu, etc.... giving the problem. I tried different browsers also but still the problem exists. Please help me out to fix this issue.
Thanks & Regards
Sriram P

scottmartin
24 Apr 2012, 8:40 PM
-Do you have a high field count where the limit would be reach in only 4 records?
-Have you verified your request is a POST?
-change method: 'POST' to actionMethods: 'POST',
-If you enter the URL manually in a browser, do you see all of the data returned?

Regards,
Scott