PDA

View Full Version : Template in Container



crocop21
5 Jun 2012, 1:25 PM
Hi all, i am trying to implement a little example of a template in a Container, i am working with extjs4 mvc, its shows nothing, in blank..


i have mi model

Ext.define('MyApp.model.user', {
extend: 'Ext.data.Model',

fields: [
{
name: 'name'
},
{
name: 'photo'
}
]
});

My Store

Ext.define('MyApp.store.users', {
extend: 'Ext.data.Store',
alias: 'store.users',
requires: [
'MyApp.model.user'
],

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
storeId: 'MyJsonStore',
model: 'MyApp.model.user',
buffered: false,
proxy: {
type: 'ajax',
url: 'http://127.0.0.1/ejemsplostemplate/ejemtemplate1/ejemtemplate1/mostrar.php',
reader: {
type: 'json',
root: 'datos'
}
}
}, cfg)]);
}
});

My view with the container, here i think have the problem dont know how to pass my store to the data for can read my values


Ext.define('MyApp.view.MyContainer', {
extend: 'Ext.container.Container',

autoShow: true,
data: 'this.getusersStore();',
height: 250,
width: 400,

initComponent: function() {
var me = this;

Ext.applyIf(me, {
tpl: [
'<tpl for="data"><p><img src="{photo}" />{name}</p></tpl>'
]
});

me.callParent(arguments);
}

});

my records from my bd


{"success":true,"datos":[{"id":"1","name":"The Rock","photo":"http:\/\/images.wikia.com\/lucha-libre\/es\/images\/9\/9c\/Rock_wrestlemania_27.jpg"},
{"id":"2","name":"Hulk Hogan","photo":"http:\/\/imagenes.lapatilla.s3.amazonaws.com\/site\/wp-content\/uploads\/2012\/03\/hulk_hogan_hulk_hogan.jpg"}]}

crocop21
6 Jun 2012, 7:04 AM
Somebody can help? pls..

mitchellsimoens
7 Jun 2012, 1:47 PM
Don't want to use the dataview that will handle it for you?