Reputation: 228
So, I'm new to Extjs, and as part of my learning I'm trying to create a simple FAQ-Style tree list.
All the examples I've seen involve creating the UI widget (Please forgive the loose terminology) in the view file, and in a separate ViewModel file actually populating the list with its data. It looks something like
Ext.define('Namespace.view.tree.TreeList',
...
...
items:[{
xtype: 'treelist',
reference: 'treelist',
bind: '{navItems}'
}]
with the parents and children of the tree laid out in a store called navItems.
Is there a way I can merge the two files into one? Can I define the trees data inside the same items as the tree? Or failing that, can I define the store in the same .js?
I apologize if these are stupid questions - I'm more far familiar with CPP than Java.
Upvotes: 2
Views: 311
Reputation: 3629
Sure, you can define it directly in the view. The store config in the treelist accepts also object. So you can define the store directly in it.
Ext.create('Ext.panel.Panel', {
fullscreen: true,
title: 'Tree',
items: [{
xtype: 'treelist',
store: {
root: {
// data defined in here
}
}
}]
});
You can see it in action here: https://fiddle.sencha.com/#fiddle/1h0b
Upvotes: 3