I've got a dataview that displays json data from a store.
Ext.define('app.view.Abouttest', {
extend: 'Ext.Panel',
xtype: 'abouttest',
config: {
title: 'Player Info',
iconCls: 'user',
layout: 'vbox',
scrollable: true,
height: 800,
fullscreen: false,
items: [
{
docked: 'top',
xtype: 'toolbar',
id: 'toolbarId',
title: 'Player Info'
},
{
xtype: 'dataview',
store: 'Articles',
itemTpl: '<div>{content}</div>',
height: 400
}
]
}
});
</pre>
this is the model and the store which is also used in a nested list in another view:
<pre>
Ext.define('app.model.Article', {
extend: 'Ext.data.Model',
config: {
fields: [
'id',
{name: 'parent', type: 'int'},
{name: 'title', type: 'string'},
{name: 'content', type: 'string'}
]
}
});
Ext.define('app.store.Articles', {
extend: 'Ext.data.Store',
requires: ['app.model.Article'],
config: {
model: 'app.model.Article',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'resources/json/articles.json',
noCache: false,
enablePagingParams: false,
reader: {
type: "json",
rootProperty: 'pages'
}
}
}
});
</pre>
What code can be added to the Abouttest view to filter the store data to display one record based on its ID?
Here is the final version of the view
<pre>
Ext.define('app.view.Abouttest', {
extend: 'Ext.Panel',
xtype: 'abouttest',
config: {
title: 'Player Info',
iconCls: 'user',
layout: 'vbox',
scrollable: true,
height: 800,
fullscreen: false,
items: [
{
docked: 'top',
xtype: 'toolbar',
id: 'toolbarId'
},
{
xtype: 'dataview',
store: 'Articles',
itemTpl: '<div>{content}</div>',
height: 400
}
]
},
initialize: function( eOpts ) {
var store = Ext.getStore('Articles');
if (store.loading) {
store.on('load', function () {
store.filterBy(function(rec) {
return rec.get('id') === '246';
});
});
}
}
});
</pee>