PDA

View Full Version : how to print javascript variable in xtemplate



thiszparveen
9 Oct 2012, 3:00 AM
Hi,

I need to print javascript variable(global variable) into xtemplate. Below is the code. I need to print "ciacid" variable into xtemplate. could any one help me to resolve this?

Thanks in advance.

Ext.onReady( function ( ) {
var ciacid = "";
var browserURL = window.location.href;
if (browserURL.indexOf("?") > -1 ) {
var qr = browserURL.split('?')[1];
var arrQrStr = new Array();
var arr = qr.split('&');

for (var i=0;i<arr.length;i++){
var queryvalue = arr[i].split('=');
if(queryvalue[0] == 'CIACID') {
ciacid = queryvalue[1];
}
}
}

var tpl2 = new Ext.XTemplate(
'<center><b style="font-size: 20px !important;">Error: Invalid ID value {ciacid} </b></center>'
);




var panel2 = new Ext.Panel({
renderTo: '#divName#',
tpl: tpl2
});
});

Legolas
9 Oct 2012, 3:14 AM
thiszparveen, you may concatenate the variable in your templade, as below:

var tpl2 = new Ext.XTemplate(
'<center><b style="font-size: 20px !important;">Error: Invalid ID value ' + ciacid +'</b></center>'
);