PDA

View Full Version : how to get datareader's Json data



shahab_et
22 Jan 2011, 7:01 AM
Hi again !

I have data Store, and here is the code that generates my store :

var id = myRecord!=null ? myRecord.get('id'): '0';

var ds = new Ext.net.Store({
autoLoad: false,
url: "/industrialWebClient/seam/resource/myresource?op=2&id="+id,
storeId: 'myStore',
reader: new Ext.data.JsonReader({
fields: [
{name: 'id'},
{name: 'rowNumber'},
{name: 'desc'},
{name: 'ledgerCodetxt'},
{name: 'ledgerName'},
{name: 'floatingtxt'},
{name: 'floatingName'},
{name: 'projecttxt'},
{name: 'projectName'},
{name: 'costCentertxt'},
{name: 'costCenterName'},
{name: 'articleCurrencytxt'},
{name: 'articleCurrencyName'},
{name: 'currencyAmount'},
{name: 'currencyRate'},
{name: 'version'},
{name: 'creatorUser'},
{name: 'enabled'},
{name: 'modifierUser'},
{name: 'cleared'},
{name: 'referenceNumber'},
{name: 'debit',type: 'float'},
{name: 'credit',type: 'float'}
],
idProperty: '',
root: 'rows',
totalProperty: 'totalCount'
})
});
and there is a functions that is supposed to send the store's data (in json format) to the server side :

var modifyDocument = function (){

// here is the problem !!!
var obj = ds.reader.jsonData;
DocForm.getForm().submit({
method:'POST',
url:'/industrialWebClient/seam/resource/myresource?op=9',
params: {
id: myRecord.get('id'),
storeData: obj
},
success:function(form,action)
{
Ext.Msg.alert('Success', action.result.msg);
},
failure :function(form,action)
{
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'please fill the form completely');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Server reported:'+action.response.status+' '+action.response.statusText);
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}})
}and here is where the function is called :


var tb = new Ext.Toolbar({
items: [ {
text: 'Modify',
id:'modifyDocument',
handler: function() {
modifyDocument();
}} ]
});problem is that no data is received on the server side when I try to call the "modifyDocument".

Condor
22 Jan 2011, 7:40 AM
ds.reader.jsonData contains the original data (that was initially loaded).

I assume you want to send the current data?

var data = [];
ds.each(function(rec){
data.push(rec.data);
});
DocForm.getForm().submit({
url:'/industrialWebClient/seam/resource/myresource?op=9',
params: {
id: myRecord.get('id'),
storeData: Ext.encode(data)
},
...
}):

shahab_et
22 Jan 2011, 8:26 AM
Thank you,
that's what I was looking for .

sorry about my primary questions!!!
I used to develop desktop applications using C# and now EVERYTHING has changed ... I'm learning Java , Java Script , ExtJs and Web programming !!!
I'm totally in a new world ,and really need help .

Thank you again.