PDA

View Full Version : Display HTML from database in panel or textarea or text or something!



ctantalo
19 Nov 2012, 1:38 PM
I have something that I think would be very simple and easy to implement, but everything I have tried.. falls short.

My model and store work fine, returning data, etc. One field in my model is type String, and contains HTML text.
When it is displayed in my panel, which just houses one TEXTAREA, the tags and such are there.

How do I display this as just HTML? I have tried functions to do an encode, but either I have syntax wrong, or this cant be simply done.

BTW< it doesnt have to be a textarea, but can be a panel, or whatever to make this work.

Ext.create('Ext.form.Panel', {
height: 500,
columnWidth: .6,
bodyPadding: 10,
defaults: {
anchor: '100%',
labelWidth: 100
},
items :[

{
xtype :'textareafield',
name: 'testProcDesc',
fieldLabel: 'Description',
height: 300,
readOnly: true
}

suzuki1100nz
19 Nov 2012, 5:53 PM
Just set the html config on the panel - it will be added to the body of the panel

ctantalo
20 Nov 2012, 5:57 AM
if you are talkiing about adding
HTML: true,

I already tried that to no success :(

suzuki1100nz
20 Nov 2012, 10:48 AM
Hi,
Have a look at the API - http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Component-cfg-html
(http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Component-cfg-html)
There is an html config defined on AbstractComponent and available to all subclasses.
It takes a string or an object.

e.g.

{
xtype : 'container',
html : '<h1><b> I am an html string</b></h1>'
}

You could set this config from your datastore or use a custom renderer - XTemplate

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.XTemplate