PDA

View Full Version : How to set character encoding for a dataStore



shahab_et
27 Dec 2010, 10:24 PM
Hi everybody,
when i try to submit a grid Store i get some invalid characters in the json string.
and I should mention I'm newbie to Extjs.

note : i use Persian language which is right to left

returned value is something like this :

"Updated":[{"desc":"??? ??","credit":1000,"id":-1},{"desc":"??? ??","debit":2500,"id":-2}]

and "desc" is a field that is holding some text



Thanks for your time.

Shahab

renku
28 Dec 2010, 12:46 AM
I don't think Store has anything to do with encoding issues. Encoding is specified for the whole page and all the communication with server should happen in the same encoding. If you try to mix things, bad things will happen.

It would be better if you provided an example page that demonstrated this issue you are having. You are currently giving us way too little information, not even mentioning the name of the charset.

Condor
28 Dec 2010, 12:46 AM
How are you 'submitting' a grid store? Are you sending the data with an Ext.Ajax.request or are you using an Ext.data.Writer?

The key is to do all communication with the UTF-8 character set by setting the request header Content-type to include ;charset=UTF-8.

shahab_et
28 Dec 2010, 12:56 AM
this is the code I'm using for save button handler and defining the store
hope it helps...

and thank you


=============================Store
var ds = new Ext.net.Store({
autoLoad: true,
url: "/industrialWebClient/seam/resource/myresource?op=5",
reader: new Ext.data.JsonReader({
fields: [
{name: 'id'},
{name: 'rowNumber'},
{name: 'desc'},
{name: 'ledgerCode'},
{name: 'floating'},
{name: 'project'},
{name: 'costCenter'},
{name: 'articleCurrency'},
{name: 'currencyAmount'},
{name: 'currencyRate'},
{name: 'amount'},
{name: 'debitCredit'}
],
totalProperty: 'totalCount',
root: 'rows'
}),
storeId: 'myStore'
});

========================Save button handler

{
text: 'Save',
handler: function() {
var obj = Ext.StoreMgr.get('myStore').getChangedData();

formPanel.getForm().submit({
url:'/industrialWebClient/seam/resource/myresource?op=4',
params: {
storeData: obj
},
callback: function(form, action, success) {
alert('Done...');
}
})
}

Condor
28 Dec 2010, 1:22 AM
1. What does getChangeData return?
2. Don't you want:

params: obj
or

jsonData: obj
3. That formpanel, is it configured with standardSubmit:true or does it do an Ajax style submit?
4. Do you actually need a form or would a normal Ext.Ajax.request work too?

shahab_et
28 Dec 2010, 2:22 AM
I've set "standardSubmit:true" for the formpanel ,...problem still exists
and couldn't find the difference between
params and jsonData !! should I pass the stroe through this property(jsonData) ?

as I said earlier I'm newbie to ExtJs

Condor
28 Dec 2010, 2:24 AM
No, I think you want standardSubmit:false (I was just asking if you'd set it to true).

You didn't answer my first question: What does getChangeData() return?

And does this form contain other fields or are you just using it to send store data?

shahab_et
28 Dec 2010, 2:53 AM
My form is somehow like an Invoice which has some fields on header part and also a grid that's for the items(the rows).
All I need is to submit the whole form so that i can get the data (the header fields and the grid store).

I had a sample code in which "getChangedData" was said to return the changed data (all the data in the store)

when I remove getChangedData I get "[object Object]" instead of the json string within the store.

what is the standard way of submitting a grid store in extJs.


sorry for my primary questions !!!

Thank you

Condor
28 Dec 2010, 4:15 AM
There is no standard way of submitting store data. It all depends how your server is expecting the data to be formatted.