Ext


Go Back   Ext JS Forums > Ext JS Community Forums (2.0) > Ext 2.x: Help

Reply
 
Thread Tools
  #1  
Old 08-27-2008, 03:43 PM
rrochap's Avatar
rrochap rrochap is offline
Ext User
 
Join Date: May 2008
Location: Barranquilla,Colombia
Posts: 20
rrochap is on a distinguished road
Default problem display'n information on a textfield

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&#039 when i show it on a textfield or a textarea,
how can i fix that?
Reply With Quote
  #2  
Old 09-05-2008, 10:28 AM
rrochap's Avatar
rrochap rrochap is offline
Ext User
 
Join Date: May 2008
Location: Barranquilla,Colombia
Posts: 20
rrochap is on a distinguished road
Default

any idea????
Reply With Quote
  #3  
Old 09-05-2008, 10:31 AM
Darklight Darklight is offline
Ext User
 
Join Date: Apr 2007
Posts: 177
Darklight is on a distinguished road
Default

&#039 ; 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
Reply With Quote
  #4  
Old 09-05-2008, 10:36 AM
Condor's Avatar
Condor Condor is offline
Ext JS - Community Support Team
 
Join Date: Mar 2007
Location: The Netherlands
Posts: 14,250
Condor is on a distinguished road
Default

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).
Reply With Quote
  #5  
Old 09-05-2008, 10:42 AM
rrochap's Avatar
rrochap rrochap is offline
Ext User
 
Join Date: May 2008
Location: Barranquilla,Colombia
Posts: 20
rrochap is on a distinguished road
Default thnks..

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...
Reply With Quote
  #6  
Old 09-05-2008, 10:46 AM
rrochap's Avatar
rrochap rrochap is offline
Ext User
 
Join Date: May 2008
Location: Barranquilla,Colombia
Posts: 20
rrochap is on a distinguished road
Default Code and Json...

Json..

{"results":[{"id_":"'A'","nom":"'B'","tip":"'C'","des":"'D'","sql":"'E'"}]}
hey, in this part instead of ( ' ) the json response is with ( & 0 3 9 ; ) but when it paste it and show it.. just transform it..

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'
			}]
Reply With Quote
  #7  
Old 09-05-2008, 10:58 AM
Darklight Darklight is offline
Ext User
 
Join Date: Apr 2007
Posts: 177
Darklight is on a distinguished road
Default

you could try Ext.util.Format.htmlDecode()
Reply With Quote
  #8  
Old 09-05-2008, 11:07 AM
Condor's Avatar
Condor Condor is offline
Ext JS - Community Support Team
 
Join Date: Mar 2007
Location: The Netherlands
Posts: 14,250
Condor is on a distinguished road
Default

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}
]
...
with
function decode039(v) {
	return !v ? v : String(v).replace(/& #039;/g, "'");
}
ps. Remove the space between & and #039.
Reply With Quote
  #9  
Old 09-05-2008, 11:11 AM
rrochap's Avatar
rrochap rrochap is offline
Ext User
 
Join Date: May 2008
Location: Barranquilla,Colombia
Posts: 20
rrochap is on a distinguished road
Default ...

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?
Reply With Quote
  #10  
Old 09-05-2008, 11:15 AM
Darklight Darklight is offline
Ext User
 
Join Date: Apr 2007
Posts: 177
Darklight is on a distinguished road
Default

maybe the grid has htmldecode built in. the easiest way would still be to have your backend send it correctly
Reply With Quote
Reply

Thread Tools

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT -5. The time now is 02:46 AM.

© 2006-2009 Ext, LLC
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.