PDA

View Full Version : How to loading view content with ext js 4.1



kenny3431
2 May 2012, 9:49 PM
Dear all.

I'm newbie, and i have question about ext js 4.

My directory:

-resources
- app
------controller
-----------------Hello.js
------view
-----------------Hello.js
------app.js
- extjs
File app.js:

Ext.Loader.setConfig({ enabled: true });
Ext.application({
name:"test",
appFolder:'app',
controllers:['Hello'],
launch:function(){
Ext.create("Ext.container.Viewport",{
items:{
xtype:'Helloview',
}
})
}
})


file view/Hello.js

Ext.define('test.view.Hello',{
extend:'Ext.grid.Panel',
alias:'Widget.Helloview',
items:[
{
title:'Test',
html:'Hello Ext Js 4.1'
}
]

})


file controller/Hello.js

Ext.define("test.controller.Hello",{
extend:"Ext.app.Controller",
views:['Hello'],
init:function(){
console.log('Hello controller call')
}
})


but i get error: Uncaught TypeError: Cannot call method 'substring' of undefined
So, please help me load content with view

vietits
2 May 2012, 10:30 PM
Try to fix your view as below


Ext.define('test.view.Hello',{
extend:'Ext.grid.Panel',
alias:'widget.Helloview', // <- widget is in lowercase
items:[
{
title:'Test',
html:'Hello Ext Js 4.1'
}
]
})

kenny3431
2 May 2012, 10:53 PM
Thanks for your reply.
But i get another problem:
Uncaught TypeError: Cannot read property 'items' of undefined

vietits
2 May 2012, 11:10 PM
Ext.define('test.view.Hello',{
extend:'Ext.grid.Panel',
alias:'widget.Helloview', // <- widget is in lowercase
items:[{
title:'Test',
html:'Hello Ext Js 4.1'
}]
});


With Ext.grid.Panel, you should define columns not items.
To test, you should use Ext.panel.Panel instead of Ext.grid.Panel.

kenny3431
2 May 2012, 11:20 PM
Thanks, problem fixed.