tonyx
30 Aug 2011, 4:44 PM
I'm a bit new to Ext Js 4 and trying to find my way around by re-creating the nested loading example application (http://docs.sencha.com/ext-js/4-0/#!/example/app/nested-loading/nested-loading.html) from scratch provided by Ext. Here is my viewport file and book SideBar file
viewport.js
Ext.define("Books.view.Viewport", {
extend: "Ext.container.Viewport",
layout: "fit",
items: {
xtype: 'panel',
border: false,
id : 'viewport',
layout: {
type: 'vbox',
align: 'stretch'
},
dockedItems: [
Ext.create("Books.view.Header"),
Ext.create("Books.view.book.Sidebar")
],
items: [
{
......
Sidebar.js
Ext.define("Books.view.book.Sidebar", {
extend: "Ext.view.View",
alias: "widget.booksidebar",
id: "sidebar",
dock: "left",
width: 180,
border: false,
cls: "sidebar-list",
selModel: {
deselectOnContainerClick: false
},
store: "Books",
itemSelector: ".product",
tpl: new Ext.XTemplate(
'<div class="sidebar-title">Books</div>',
'<tpl for=".">',
'<div class="product">{name}</div>',
'</tpl>'
)
});
The problem is, however, that sidebar is not rendered. And if I were to try to call this.getBookSideBar().refresh() in the controller, I get the following error in console
me.store is undefined
records = me.store.getRange(); ext-all-debug-w-comments.js (line 83524)
However, if I were to inline the sidebar within viewport.js, then everything works perfectly
viewport.js with sidebar inlined
Ext.define("Books.view.Viewport", {
extend: "Ext.container.Viewport",
layout: "fit",
items: {
xtype: 'panel',
border: false,
id : 'viewport',
layout: {
type: 'vbox',
align: 'stretch'
},
dockedItems: [
Ext.create("Books.view.Header"),
{
xtype: "dataview",
dock: "left",
width: 180,
border: false,
cls: "sidebar-list",
selModel: {
deselectOnContainerClick: false
},
store: "Books",
itemSelector: ".product",
tpl: new Ext.XTemplate(
'<div class="sidebar-title">Books</div>',
'<tpl for=".">',
'<div class="product">{name}</div>',
'</tpl>'
)
}
],
items: [
{
......
Why is this the case? How come I couldn't specify the store within the view file?
PS: The example itself uses this.getBookSideBar().bindStore(this.getBooksStore()); with no problem, but I was trying to understand why wouldn't it just use the store configuration inside the view itself
viewport.js
Ext.define("Books.view.Viewport", {
extend: "Ext.container.Viewport",
layout: "fit",
items: {
xtype: 'panel',
border: false,
id : 'viewport',
layout: {
type: 'vbox',
align: 'stretch'
},
dockedItems: [
Ext.create("Books.view.Header"),
Ext.create("Books.view.book.Sidebar")
],
items: [
{
......
Sidebar.js
Ext.define("Books.view.book.Sidebar", {
extend: "Ext.view.View",
alias: "widget.booksidebar",
id: "sidebar",
dock: "left",
width: 180,
border: false,
cls: "sidebar-list",
selModel: {
deselectOnContainerClick: false
},
store: "Books",
itemSelector: ".product",
tpl: new Ext.XTemplate(
'<div class="sidebar-title">Books</div>',
'<tpl for=".">',
'<div class="product">{name}</div>',
'</tpl>'
)
});
The problem is, however, that sidebar is not rendered. And if I were to try to call this.getBookSideBar().refresh() in the controller, I get the following error in console
me.store is undefined
records = me.store.getRange(); ext-all-debug-w-comments.js (line 83524)
However, if I were to inline the sidebar within viewport.js, then everything works perfectly
viewport.js with sidebar inlined
Ext.define("Books.view.Viewport", {
extend: "Ext.container.Viewport",
layout: "fit",
items: {
xtype: 'panel',
border: false,
id : 'viewport',
layout: {
type: 'vbox',
align: 'stretch'
},
dockedItems: [
Ext.create("Books.view.Header"),
{
xtype: "dataview",
dock: "left",
width: 180,
border: false,
cls: "sidebar-list",
selModel: {
deselectOnContainerClick: false
},
store: "Books",
itemSelector: ".product",
tpl: new Ext.XTemplate(
'<div class="sidebar-title">Books</div>',
'<tpl for=".">',
'<div class="product">{name}</div>',
'</tpl>'
)
}
],
items: [
{
......
Why is this the case? How come I couldn't specify the store within the view file?
PS: The example itself uses this.getBookSideBar().bindStore(this.getBooksStore()); with no problem, but I was trying to understand why wouldn't it just use the store configuration inside the view itself