|
|||||||
![]() |
|
|
Thread Tools |
|
#1
|
||||
|
||||
|
I store informacion on my database, in using mysql i bring some information to my form using json. on the data base for example is stored 'en' but on the form appears 'en' when i show it on a textfield or a textarea,
how can i fix that? |
|
#2
|
||||
|
||||
|
any idea????
|
|
#3
|
|||
|
|||
|
' ; is the ' sign. your backend probably returns it like this, so you should look for the fix there. check with FireBug what is delivered via json
|
|
#4
|
||||
|
||||
|
You should post the source (that you already PM'ed me).
Also, post the data that is actually received from the server (use Firebug's Net tab). |
|
#5
|
||||
|
||||
|
hey men thnks 4 ur help..
now i check the json response and ur right, it comes with ' but.. when i show it in the grid it shows ( ' ) thats ok.... but when it shows on a text field, shows ' .. i think. the problem is the way that the information is decode by the grid or texfield is different.. i dont know... ![]() |
|
#6
|
||||
|
||||
|
Json..
{"results":[{"id_":"'A'","nom":"'B'","tip":"'C'","des":"'D'","sql":"'E'"}]}
Code... var form = new Ext.FormPanel({
region:'center',
el:'main-form',
width:'100%',
bodyStyle:'padding:5px 5px 0',
labelWidth:75,
labelAlign:'right',
reader: new Ext.data.JsonReader({
root:'results',
id: 'id_',
fields: ['id_', 'nom', 'tip', 'des', 'sql']
}, [
{name:'query.id', mapping:'id_'},
{name:'query.nombre', mapping:'nom'},
{name:'query.tipo', mapping:'tip'},
{name:'query.descripcion', mapping:'des'},
{name:'query.sql', mapping:'sql'},
]),
layout:'form',
defaults:{ width:250 },
items: [{
xtype:'hidden',
name:'query.id'
},frm_tipos,
{
xtype:'textfield',
fieldLabel:"Nombre",
name:'query.nombre',
allowBlank:false,
maxLength:20
},{
xtype:'textarea',
fieldLabel:"Descripcion",
name:'query.descripcion',
allowBlank:false,
maxLength:150
},{
xtype:'textarea',
fieldLabel:"Query",
allowBlank:false,
height:200,
width:400,
name:'query.sql'
}]
|
|
#7
|
|||
|
|||
|
you could try Ext.util.Format.htmlDecode()
|
|
#8
|
||||
|
||||
|
So your server is already sending the & #039; ?
In that case the JsonReader needs to decode the values: ...
[
{name:'query.id', mapping:'id_', convert: decode039},
{name:'query.nombre', mapping:'nom', convert: decode039},
{name:'query.tipo', mapping:'tip', convert: decode039},
{name:'query.descripcion', mapping:'des', convert: decode039},
{name:'query.sql', mapping:'sql', convert: decode039}
]
...
function decode039(v) {
return !v ? v : String(v).replace(/& #039;/g, "'");
}
|
|
#9
|
||||
|
||||
|
ok .. but for each field of my form???? i think its a little. difficult.. cause i have a lot of forms... but.. i still don't understand.. why works with grids and not with textfields, textareas and comboxes..
there's not a better way to do that? |
|
#10
|
|||
|
|||
|
maybe the grid has htmldecode built in. the easiest way would still be to have your backend send it correctly
![]() |
![]() |
| Thread Tools | |
|
|