How to pass on data from form and parse using tpl in ExtJS -


i have designed form , wanted generate output using tpl file.

all examples in sench provided scenarios "data" attribute prepopulated json or xml data , how renderit using "tpl".

pls see code :

#

<!doctype html> <html> <head> <link href="http://cdn.sencha.com/ext/gpl/4.2.0/resources/css/ext-all.css" rel="stylesheet" /> <script src="http://cdn.sencha.com/ext/gpl/4.2.0/ext-all.js"></script> <script> ext.onready(function () {     ext.define("customlink",{         xtype:"link",         extend:"ext.component",         tpl:'<div style="margin:40px 40px"><a style="font-size:32px;text-transform: capitalize" href="{url}">{text}</a><div style="margin-top:20px">{paragraph}</div></div>',         initcomponent:function(){             this.data={                 text:this.text,                 url:this.url,                 paragraph:this.paragraph             };             this.callparent(arguments);         },         renderto:ext.getbody()     });     ext.create("customlink",{"text":"google","url":"http://www.google.com","paragraph":"lorem ipsum dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book. has survived not 5 centuries, leap electronic typesetting, remaining unchanged. popularised in 1960s release of letraset sheets containing lorem ipsum passages, , more desktop publishing software aldus pagemaker including versions of lorem ipsum."}); }); </script> </head> <body> </body> </html> 

#

the above code generate heading hyperlink followed paragraph.

now if want provide link,title text , paragraph using form 2 textfields( 1 title,one url) , 1 textarea(for paragraph) components.

how achieve this?

you can read data form using var formdata = form.getform().getvalues() , update link using link.update(formdata)

var form = this.up('form'); link.update(form.getform().getvalues()); 

https://fiddle.sencha.com/#fiddle/189e


Comments