I hava a php variable that contain JSON type data.
$list = [{"id":"10","first_name":"first","mi_name":"","last_name":"last","nick_name":"HH"}];
and I need to use the date for EXT-JS XTemplate.
I tried this way,
var myStore = <?php echo $list; ?>;
var myTpl = new Ext.XTemplate(
"<div style='text-align:center'>",
'<tpl for=".">',
'<p> No : {#}</p>',
'<p>{first_name} {$last Name}</p>',
"</tpl>",
"</div>",
{}
);
var myPanel = new Ext.Panel({
border : true,
layout : 'fit',
pageY : 10,
items : new Ext.DataView({
store : myStore,
tpl : myTpl,
autoHeight : true,
emptyText : 'No Data'
})
});
but it does not work,
also I tried this,
var myStore = Ext.create('Ext.data.JsonStore', {
autoLoad : true,
data : <?php echo $list; ?>
});
it does not work either.
so I tried to get the data using proxy.
var myStore = new Ext.data.JsonStore({
proxy : new Ext.data.HttpProxy({
url : './index.php?action=getList' //it return same to $list
}),
fields : [
{name : 'first_name', type : 'string'},
{name : 'last_name', type : 'string'}
],
autoLoad : true
});
and It works!
Hmm…
so my question is how can I create the data with JSON type php variable.
(I do not want to use proxy to get data if I can)
help me~!
Your dataview is missing the mandatory config “
itemSelector”For more info, please read the sencha documentation Sencha ExtJS 4 dataview