KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm testing out extjs 4 and I have stumbled upon something, I can't seem to figure out. I have simple object association: Snapshot - hasMany -> Model Now, I am trying to use XTemplate to show this association in View component, so I have my XTemplate looking like this: Ext.create('Ext.XTemplate', '<tpl for=".">', '<div class="snapshot" id="{id}">', '<h1>{snapshot}</h1>', '<p><span class="label">Created: </span>{dateString}</p>', '<p><span class="label">Models</span></p>', '<tpl for="models">', '<p>{name} - {description}</p>', '</tpl>', '</div>', '</tpl>', '<div class="x-clear bottompad"></div>' ); And my JSON response looks like this (showing just 'snapshot' node): { "id": 1, "snapshot": "Snapshot 1", "created": 1305806847000, "models": [ { "id": 1, "name": "ABC", "description": "A B C" }, { "id": 111, "name": "ABCDD", "description": "A B C XCXC" } ] } As extjs 4 introduces concept of Model I have created models for Snapshot and Model and created association according to API docs. Snapshot model: Ext.define('Snapshot', { extend: 'Ext.data.Model', fields: [ {name: 'id', type: 'int'}, 'snapshot', {name: 'created',type: 'date', dateFormat: 'time' } ], associations:[ {type: 'hasMany', model: 'Model', name: 'models'} ], idProperty: 'id' }); Model model ;P Ext.define('Model', { extend: 'Ext.data.Model', belongsTo: 'Snapshot', fields: [ { name: 'id', type: 'int' }, { name: 'snapshot_id', type: 'int' }, 'name',
Tags (comma-separated)
Save Edits
Cancel