Sencha touch List - extjs

I'm new in sencha touch. I run into some strange behavior. Shortly I want to make one window with toolbar and list below.
Main launch code:
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: 'xxx',
controllers: ['Main'],
views: ['Home', 'Header', 'Footer', 'list.MainMenu'],
stores: ['MainMenu'],
models: ['MenuItem'],
launch: function() {
Ext.create('xxx.view.Viewport');
}
});
Viewport view:
Ext.define('xxx.view.Viewport', {
extend: 'Ext.Panel',
config: {
fullscreen: true,
items: [
{
xtype: 'headerpanel',
},{
xtype: 'MainMenu'
}
]
}
});
Header view:
Ext.define('xxx.view.Header', {
extend: Ext.Panel,
xtype: 'headerpanel',
config: {
items: [
{
xtype: 'titlebar',
docked: 'top',
title: '<img src="lib/resources/images/x.png" />',
items: [
{
text: 'One',
align: 'left'
},{
text: 'Two',
align: 'right'
}
]
}
]
}
});
Meniu view:
Ext.define('xxx.view.list.MainMenu', {
extend: 'Ext.List',
xtype: 'MainMenu',
requires: ['xxx.store.MainMenu'],
config: {
itemTpl: '{title}',
store: 'MainMenu'
}
});
Menu store:
Ext.define('xxx.store.MainMenu', {
extend: 'Ext.data.Store',
config: {
model: 'xxx.model.MenuItem',
data: [
{icon: 'a', title: 'A'},
{icon: 'b', title: 'B'},
]
}
});
Menu model:
Ext.define('xxx.model.MenuItem', {
extend: 'Ext.data.Model',
config: {
fields: ['icon', 'title']
}
});
The result of this piece code is just toolbar without any list.
I set layout to 'fit' value the result is opposite: only list I can see.

You forgot to set a layout to your Viewport view. Without a layout, container don't know how to display inner items.
Try the following :
Ext.define('xxx.view.Viewport', {
extend: 'Ext.Panel',
config: {
fullscreen: true,
layout:'fit',
items: [
{
xtype: 'titlebar',
docked: 'top',
title: '<img src="lib/resources/images/x.png" />',
items: [{
text: 'One',
align: 'left'
},{
text: 'Two',
align: 'right'
}]
},{
xtype: 'list',
itemTpl: '{title}',
store: 'MainMenu'
}
]
}
});
You can find more about layout here

Related

Sencha touch-how should I add a tab panel inside a panel? following answer is not working it not diaplaying content inside tab panel

Ext.define('SenchaCalc.view.TabScreen',{
extend: 'Ext.tab.Panel',
xtype: 'tabScreen',
requires: [
'Ext.tab.Panel',
],
config:{
xtype:'tabpanel',
ui: 'light',
itemId: 'tabPanel',
name: 'tabPanel',
layout:
{
animation: 'fade',
type: 'card'
},
items:[
{
title: 'HOME',
iconCls: 'home',
itemId:'home',
items:[{
xtype:'panel',
itemId:'homePanel',
height:450,
width:1010,
items:[{
xtype:'button',
itemId:'homePanelButton',
name:'homePanelButton',
html:'I m in Home Panel',
height:50,
width:350,
style:'border:0px;background:#1985D0;',
cls:'homePanelButton',
}]
}]
}]
},
{
title: 'HELP',
iconCls: 'action',
itemId:'help',
items:[{
xtype:'panel',
itemId:'helpPanel',
height:450,
width:1010,
items:[{
xtype:'button',
itemId:'helpPanelButton',
name:'helpPanelButton',
html:'I m in Help Panel',
height:50,
width:350,
style:'border:0px;background:#1985D0;',
cls:'helpPanelButton',
}]
}]
}],
}
});
/******************************************************************************/
Ext.define('SenchaCalc.view.MainScreen',{
extend: 'Ext.Panel',
xtype: 'mainScreen',
requires: [
'Ext.tab.Panel',
],
config:{
xtype: 'panel',
items:[
xtype: 'tabScreen',
]
}
});
How you are handling navigation between panel and tabscreen in your MainScreen? If you have any controller paste the code. You have not mentioned any layout there. If you want to present them in different screen then please use card layout for MainScreen. For testing of nested tabpanel inside panel I have used vbox layout and pasted the code here. Please run this on sencha jsfiddle for testing.
Ext.application({
name: 'Sencha',
launch: function() {
Ext.create("Ext.Panel", {
fullscreen: true,
xtype: 'mainScreen',
layout: {
type: 'vbox'
},
requires: [
'Ext.tab.Panel',
],
items:[
{
xtype: 'panel',
flex:1,
style: 'background:red',
html:'Main screen data'
},
{
xtype: 'tabpanel',flex:1,
tabBarPosition: 'bottom',
defaults: {
styleHtmlContent: true
},
items: [
{
title: 'Page1',
iconCls: 'home',
html: 'Panel screen data page1'
},
{
title: 'Page2',
iconCls: 'user',
html: 'Panel screen data page2'
}
]
}
]
});
}
});

Sencha Touch 2.2.0 form panel does not show up

It is empty.
Ext.define('odtu.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'main',
requires: [
'Ext.TitleBar',
'Ext.Video',
'Ext.form.Panel',
'Ext.form.FieldSet',
'Ext.field.Password',
'Ext.field.Email'
],
config: {
tabBarPosition: 'bottom',
items: [
{
title: 'Giriş',
iconCls: 'home',
styleHtmlContent: true,
scrollable: true,
items: [
{
docked: 'top',
xtype: 'titlebar',
title: 'm.odtu.lu'
},
{
xtype: 'formpanel',
url: 'register.php',
items:{
xtype: 'fieldset',
items:
[
{
xtype: 'textfield',
name : 'name',
label: 'Name'
},
{
xtype: 'emailfield',
name : 'email',
label: 'Email'
},
{
xtype: 'passwordfield',
name : 'password',
label: 'Password'
}
]
}
}
]
},
{
title: 'Kaydol',
iconCls: 'compose',
items: [
{
docked: 'top',
xtype: 'titlebar',
title: 'Kaydol'
},
{
xtype: 'video',
url: 'http://av.vimeo.com/64284/137/87347327.mp4?token=1330978144_f9b698fea38cd408d52a2393240c896c',
posterUrl: 'http://b.vimeocdn.com/ts/261/062/261062119_640.jpg'
}
]
}
]
}
});
Set a height to your formpanel
{
...
height: 100 // for instance
...
}
Or you can use a fit layout on your Giriş panel if you want the formpanel to take the whole height
{
title: 'Giriş',
iconCls: 'home',
layout: 'fit'
...
}
Hope this helps

panel not showing sencha touch 2

I'm trying to switch panels when tapping 'login' in a toolbar.
My controller gets the event and I switch by adding and setting the active item to the panel I want.. however, the screen stays blank (and there are no debug errors).
This is the code of my panel, any idea what the mistake might be?
Ext.define('App.view.LoginView', {
extend: 'Ext.Panel',
xtype: 'loginpanel',
alias: 'widget.loginView',
fullscreen: true,
layout: 'fit',
items: [
{
xtype: 'TopToolBar'
},
{
xtype: 'formpanel',
items: [
{
xtype: 'fieldset',
title: 'Login',
instructions: 'Have a great day!',
items: [
{
xtype: 'emailfield',
name: 'email',
label: 'Email'
},
{
xtype: 'passwordfield',
name: 'password',
label: 'Password'
}
]
},
{
xtype: 'button',
text: 'Login',
ui: 'confirm',
handler: function()
{
this.up('loginpanel').submit();
}
}
]
}]})
The code of my toolbar class:
Ext.define('App.view.TopToolBar', {
extend: 'Ext.Toolbar',
xtype: 'TopToolBar',
dock: 'top',
initialize: function() {
var loginButton = {
xtype: 'button',
text: 'Login',
ui: 'action',
handler: this.onLoginTap,
scope: this
};
this.add(loginButton);
},
onLoginTap: function(){
console.log('login tap');
this.fireEvent('loginBtnHandler', this);
}})
Define classes with Ext.define.
Ext.define('My.Toolbar', {
extend: 'Ext.Toolbar',
alias: 'widget.mytoolbar'
//configuration
});
Create(Instantiate) classes with Ext.create
var tlb= Ext.create('My.Toolbar', {
//configuration
});

Adding carousel to panel

First program logic:
I have a main panel and there is a list at the left side and another panel at the right side.
When user touches the list item some html appears in right panel. What i need to do is using carousel instead of right panel.
My view
Ext.define('MyApp.view.MyPanel', {
extend: 'Ext.Panel',
xtype:'mypanel',
config: {
ui: 'dark',
layout: {
type: 'card'
},
items: [
{
xtype: 'titlebar',
docked: 'top',
title: 'Lezzet Dunyasi',
},
{
xtype: 'list',
docked: 'left',
id: 'mylist',
ui: 'round',
pinHeaders: false,
grouped: true,
//disableSelection: true,
width: 331,
itemTpl: [
'<img src="{img_url}" width="60" heigh="60"></img><span>{label}</span>'
],
store: 'Menius',
items: [
{
xtype: 'searchfield',
docked: 'top',
placeHolder: 'Search...',
},
]
},
{
xtype: 'panel',
styleHtmlContent:true,
style: {
backgroundImage: 'url(resources/img/Landscape.png)',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center'
},
id:'mypanel'
}
]
}
});
As you can see there is a xtype:panel and i tried to modify that code and i did it like this
xtype: 'carousel',
defaults{
styleHtmlContent:true,
id:'mypanel'},
items: [
{
html : 'Item 1',
style: 'background-color: #5E99CC'
},
{
html : 'Item 2',
style: 'background-color: #759E60'
},
{
html : 'Item 3'
}
]
Also i use a controller
Ext.define('MyApp.controller.MeniuController',{
extend:'Ext.app.Controller',
config:{
refs:{
leftMeniu:'mypanel list[id=mylist]',
myPanel:'mypanel panel[id=mypanel]'
},
control:{
leftMeniu:{
itemtap:'onItemTap'
}
}
},
onItemTap:function(list, index, item, record, e , opts)
{
var content = '<h2>' + record.get('label') +'</h2>' + record.get('html');
this.getMyPanel().setHtml( content );
}
});
And i modified this part like this
refs:{
leftMeniu:'mypanel list[id=mylist]',
myPanel:'mypanel carousel[id=mypanel]'
Although these modifications i can't run my code , what should i do ?
A couple of small issues that I see. You are missing a colon on defaults: And I think you want to move that id to one of your carousel elements, right? With your code, I'm only getting one page with the id defined at that level. If you move it down you will see three pages.
defaults: {
styleHtmlContent:true,
id:'mypanel' // IN WRONG PLACE?
},
[UPDATE]
I got it working so that you can write to any of your carousel panels. I just created a direct reference to each id in the refs:{} section. I'm drawing to the second page so drag it into view to see the updates.
Also, I'm adding the model, store, and app.js so that anyone reading this will have a complete working example.
Ext.define('MyApp.controller.MeniuController', {
extend:'Ext.app.Controller',
config:{
refs:{
leftMeniu:'mypanel list[id=mylist]',
// myPanel:'mypanel panel[id=mypanel]'
// myPanel:'mypanel carousel[id=mypanel]'
myFirstPanel:'#mypanel1',
mySecondPanel:'#mypanel2'
},
control:{
leftMeniu:{
itemtap:'onItemTap'
}
}
},
onItemTap:function(list, index, item, record, e, opts) {
var content = '<h2>' + record.get('label') + '</h2>' + record.get('html');
this.getMySecondPanel().setHtml(content);
this.getMyFirstPanel().setHtml(content);
}
});
Complete MyPanel View:
Ext.define('MyApp.view.MyPanel', {
extend: 'Ext.Panel',
xtype:'mypanel',
config: {
ui: 'dark',
layout: {
type: 'card'
},
items: [
{
xtype: 'titlebar',
docked: 'top',
title: 'Lezzet Dunyasi'
},
{
xtype: 'list',
docked: 'left',
id: 'mylist',
ui: 'round',
pinHeaders: false,
// grouped: true,
//disableSelection: true,
width: 331,
itemTpl: [
'{label}'
],
store: 'Menius',
items: [
{
xtype: 'searchfield',
docked: 'top',
placeHolder: 'Search...'
}
]
},
// {
// xtype: 'panel',
// styleHtmlContent:true,
// style: {
// backgroundImage: 'url(../images/risk2.png)',
// backgroundRepeat: 'no-repeat',
// backgroundPosition: 'center'
// },
// id:'mypanel'
// }
{
xtype: 'carousel',
defaults: {
styleHtmlContent:true
},
items: [
{
html: 'Item 1',
style: 'background-color: #5E99CC',
id:'mypanel1'
},
{
html: 'Item 2',
style: 'background-color: #759E60',
id:'mypanel2'
},
{
html: 'Item 3'
}
]
}
]
}
});
app.js
Ext.application({
name: "MyApp",
views: ['MyPanel'],
models: ['Meniu'],
stores: ['Menius'],
controllers: ['MeniuController'],
launch: function() {
Ext.Viewport.add(Ext.create('MyApp.view.MyPanel'));
}
});
Model:
Ext.define('MyApp.model.Meniu', {
extend: 'Ext.data.Model',
config: {
fields: ['img_url', 'label', 'html']
}
});
Store:
Ext.define('MyApp.store.Menius', {
extend: 'Ext.data.TreeStore',
config: {
model: 'MyApp.model.Meniu',
defaultRootProperty: 'items',
grouper: function(record) {
return record.get('label')[0];
},
root: {
text: 'foo',
items: [
{img_url: 'foo.png', label: 'one', html:'nice', leaf: true},
{img_url: 'foo.png', label: 'two', html:'carousels', leaf: true}
]
}
}
});

Sencha Touch 2: Trying to add a list to a panel

I have a panel which consists of a toolbar and tabs. On each tab there should be a list and a button. I believe I have this set up correctly except for the list, which I am trying to add as follows:
Ext.define('Myapp.view.Search', {
xtype: 'search',
extend: 'Ext.tab.Panel',
config: {
activeItem: 0,
tabBar: {
docked: 'top',
autoScroll: 'auto',
ui: 'light',
layout: {
pack: 'center'
}
},
items: [
{
xtype:'toolbar',
docked:'top',
ui: 'light',
title: 'Search'
},
{
title: 'Tab 1',
xtype: 'formpanel',
items: [
{
xtype: 'Mylist' //DOES NOT WORK
},
{
xtype: 'panel',
defaults: {
xtype: 'button',
style: 'margin: 0.1em',
flex : 1
},
layout: {
type: 'hbox'
},
items: [
{
text: 'Button 1',
}
]
}
]
},
{
title: 'Tab 2',
xtype: 'formpanel',
items: [
{
xtype: 'panel',
defaults: {
xtype: 'button',
style: 'margin: 0.1em',
flex : 1
},
layout: {
type: 'hbox'
},
items: [
{
text: 'Button 1',
}
]
}
]
}
]
}
});
Please let me know what I am doing wrong and thanks for you help!
EDIT: added Mylist below:
Ext.define('Myapp.view.Mylist', {
extend: 'Ext.dataview.NestedList',
xtype: 'Mylist',
config: {
store: 'Sections'
},
getTitleTextTpl: function() {
return '{name}';
},
getItemTextTpl: function(node) {
return '<strong>{name}</strong>';
},
});
Try these
in View:
{
xtype: 'panel',
flex: 4,
width: '400px',
height:"700px",
layout: {
type: 'fit'
},
items: [
{
xtype: 'list',
// loadingText:"Loading Category",
styleHtmlContent: true,
// id:"mylist2",
width:"300px",
itemTpl:
'<div class="mycon">'+
'<input type="image" id="click" img src="{coupon_image}" style="max-width:130%;border:6px double #000000;" width="200" height="200"' +'style="padding:3px;">' +
'</div>'+
'<div><font size="2" color="red"><b>Coupon Name:</b></font></div>'+
'<div><font size="2" color="green"><b>{coupon_name}</b></font></div>'+
'</div>',
store : 'ViewCategoryStore',
},
]
}
in controller:
Ext.define('Expressdeal.controller.ViewCategoryController', {
extend: 'Ext.app.Controller',
config: {
refs: {
viewcat : 'viewcategory' // xtype of the view
},
control: {
'viewcategory list: {
activate: 'onActivate',
itemtap: 'onItemTap',
},
Where you define your list in your List view you should say
alias:'widget.Mylist'
instead of
xtype:'Mylist'
also your list needs an itemTpl config im pretty sure.
config: {
store: 'Sections',
itemTpl:'{example}'
}
And as long as the store that drives your list is in working shape the list should appear correctly

Resources