Sencha Touch detailed page view into items with buttons - extjs

1.Could please anybody help me with this issue?
1.After clicking on data detail I need see something as bellow (NotesApp.view.NoteEditor):
1.button_1
1.html + {title} + html
1.button_2
1.html + {narrative} + html
app.js
Ext.application({
name: "NotesApp",
models: ["Note"],
stores: ["Notes"],
controllers: ["Notes"],
views: ["NotesList", "NoteEditor"],
launch: function () {
var notesListView = {
xtype: "noteslistview"
};
var noteEditorView = {
xtype: "noteeditorview"
};
Ext.Viewport.add([notesListView, noteEditorView]);
}
});
NotesApp.model.Note
Ext.define("NotesApp.model.Note", {
extend: "Ext.data.Model",
config: {
idProperty: 'id',
fields: [
{ name: 'id', type: 'int' },
{ name: 'title', type: 'string' },
{ name: 'narrative', type: 'string' }
]
}
});
NotesApp.store.Notes
Ext.define("NotesApp.store.Notes", {
extend: "Ext.data.Store",
config: {
model: "NotesApp.model.Note",
data: [
{ title: "Ibuprofen STDATA 200", narrative: "LIEK"},
{ title: "Ibuprofen STDATA 450", narrative: "LIEK"},
{ title: "IbuprofANIN", narrative: "LATKA"}
]
}
});
NotesApp.controller.Notes
Ext.define("NotesApp.controller.Notes", {
extend: "Ext.app.Controller",
config: {
refs: {
notesListView: "noteslistview",
noteEditorView: "noteeditorview",
notesList: "#notesList"
},
control: {
notesListView: {
editNoteCommand: "onEditNoteCommand"
},
noteEditorView: {
backToHomeCommand: "onBackToHomeCommand"
}
}
},
slideLeftTransition: { type: 'slide', direction: 'left' },
slideRightTransition: { type: 'slide', direction: 'right' },
activateNoteEditor: function (record) {
var noteEditorView = this.getNoteEditorView();
noteEditorView.setRecord(record);
Ext.Viewport.animateActiveItem(noteEditorView, this.slideLeftTransition);
},
activateNotesList: function () {
Ext.Viewport.animateActiveItem(this.getNotesListView(), this.slideRightTransition);
},
onEditNoteCommand: function (list, record) {
this.activateNoteEditor(record);
},
launch: function () {
this.callParent(arguments);
var notesStore = Ext.getStore("Notes");
notesStore.load();
},
init: function () {
this.callParent(arguments);
}
});
NotesApp.view.NotesList
Ext.define("NotesApp.view.NotesList", {
extend: "Ext.Container",
requires:"Ext.dataview.List",
alias: "widget.noteslistview",
config: {
layout: {
type: 'fit'
},
items: [{
xtype: "toolbar",
title: "Liek",
docked: "top",
}, {
xtype: "list",
store: "Notes",
itemId:"notesList",
onItemDisclosure: true,
itemTpl: "<div>{title}</div><div>{narrative}</div>"
}],
listeners: [ {
delegate: "#notesList",
event: "disclose",
fn: "onNotesListDisclose"
}]
},
onNotesListDisclose: function (list, record, target, index, evt, options) {
console.log("editNoteCommand");
this.fireEvent('editNoteCommand', this, record);
}
});
NotesApp.view.NoteEditor
Ext.define("NotesApp.view.NoteEditor", {
extend: "Ext.Container",
requires:"Ext.dataview.List",
alias: "widget.noteeditorview",
initialize: function () {
this.callParent(arguments);
},
config: {
// this is working !!!
// tpl: [
// '<div><p>Info about: {title} </p></div>'
// ],
items: [
{
xtype: "button",
text: '<div style="text-align:left;">button 1<div>',
ui: "action",
id:"button_1"
},
{
xtype: 'list',
itemTpl: [
'<div>title: {title} </div>' // working not !!!
]
},
{
xtype: "button",
text: '<div style="text-align:left;">button 2<div>',
ui: "action",
id:"button_2"
},
{
xtype: 'list',
itemTpl: [
'<div>title: {narrative} </div>' // working not !!!
]
}
]
},
});

in your controller, you attach the onEditNoteCommand handler to the editNoteCommand. This is not a valid event (and is never triggered) of the Ext.dataview.List object as you can see in the Sencha documentation.
You have to attach the handler to an existing event, in this case to the itemtap one:
control: {
notesListView: {
itemtap: "onEditNoteCommand"
},
...

Problem
You created NotesApp.view.NoteEditor as list, within that list you have two separate list for title and narrative and But in controller you setting data only for NoteEditor list, not for two list within NoteEditor, so that two list will not show any data because they didn't get data.
Can do like this
In view
Give itemId for that two list.
{
xtype: 'list',
itemId : 'title',
itemTpl: [
'<div>title: {title} </div>' // working not !!!
]
},
{
xtype: "button",
text: '<div style="text-align:left;">button 2<div>',
ui: "action",
id:"button_2"
},
{
xtype: 'list',
itemId : 'narrative',
itemTpl: [
'<div>title: {narrative} </div>' // working not !!!
]
}
In controller
activateNoteEditor: function (record) {
var noteEditorView = this.getNoteEditorView();
noteEditorView.getComponent('title').setData(record.getData().title);
noteEditorView.getComponent('narrative').setData(record.getData().narrative);
Ext.Viewport.animateActiveItem(noteEditorView, this.slideLeftTransition);
},
What you trying to do ?
First of all NotesApp.view.NoteEditor is to edit note with two fields for title and narrative.
Why you have two list for title and narrative ?
What is the purpose of that list in edit screen ?

Related

Item Click grid. Change label text

I have no trouble clicking grid items and updating textfields but do you think I change a label text? grrr
All I want to do is when I select a record set in the grid is to update the label text and text field(which it already does).
Model
Ext.define("myApp.model.ActionItem", {
extend : "Ext.data.Model",
fields : [
{
name: 'pri',
type: 'int'
},
{
name: 'request',
type: 'int'
}
]
});
Controller:
Ext.define("myApp.controller.HomeController", {
extend: "Ext.app.Controller",
id: "HomeController",
refs: [
{ ref: "ActionItemsGrid", selector: "[xtype=actionitemgrid]" },
{ ref: "DetailsPanel", selector: "[xtype=actionitemdetails]" }
],
pri: "",
models: ["ActionItem"],
stores: ["myActionStore"],
views:
[
"home.ActionItemDetailsPanel",
"home.ActionItemGrid",
"home.HomeScreen"
],
init: function () {
this.control({
"#homescreen": {
beforerender: this.loadActionItems
},
"ActionItemsGrid": {
itemclick: this.displayDetails
}
});
},
displayDetails: function (model, record) {
this.getDetailsPanel().loadRecord(record);
},
loadActionItems: function () {
var store = Ext.getStore("myActionStore");
store.load();
this.getActionItemsGrid().reconfigure(store);
}
});
View
Ext.define("myApp.view.home.ActionItemDetailsPanel", {
extend : "Ext.form.Panel",
xtype: "actionitemdetails",
items: [
{
xtype: "fieldset", defaults: { xtype: "textfield", disabled: true },
items: [
{
xtype: 'label',
forId: 'pri',
text: 'My Priority',
margin: '0 0 0 10'
},
{ id: "pri", fieldLabel: "Priority" },
{ id: "request", fieldLabel: "Requested Time" }
]
}
]
});
I found the solution from Condor a while ago. http://www.sencha.com/forum/showthread.php?106256-Form-Panel-Load-Record-and-show-the-data-in-form-label
The gist of it is that label is not a field. So in order to do what I want I need an xtype: 'displayfield' with the name of the field I want.
{
xtype: 'displayfield',
name: 'pri',
text: 'My Priority',
margin: '0 0 0 10'
}

Sencha touch list itemtap after view change

In sencha touch application I got views, one of them contains a list.
If I switch from the view which contains the list to another view and back, the list itemtap event not fires again.
My view with the list:
Ext.define('app.view.ItemList', {
extend: 'Ext.navigation.View',
xtype: 'listitems',
config: {
title: 'List',
items: [
{
xtype: 'toolbar',
ui: 'light',
docked: 'top',
title: 'List',
items: [
{
xtype: 'button',
text: 'Back',
ui: 'back',
handler: function() {
Ext.Viewport.animateActiveItem({xtype:'main'}, {type:'slide'});
}
},
]
},
{
xtype: 'list',
itemTpl: '{"name"}',
store: {
autoLoad: true,
fields: ['name', 'email'],
proxy: {
type: 'rest',
url: 'data/data.json',
reader: {
type: 'json'
}
}
}
}]
},
initialize: function() {
this.callParent();
}
})
Controller for this:
Ext.define('app.controller.Main', {
extend: 'Ext.app.Controller',
config: {
refs: {
listitems: 'listitems'
},
control: {
'listitems list': {
itemtap: 'showItem',
}
}
},
showItem: function(list, index, element, record) {
this.getItemlist().push({
xtype: 'panel',
title: record.get('name'),
html: [
"<b>Name:</b> " + record.get('name') +
"<b>Email:</b> " + record.get('email')
],
scrollable: true,
styleHtmlContent: true
})
}
})
I tried it also with id, itemId, nothing worked.
How could I solve this?
Please try sth like this:
this.getItemlist().push(
Ext.create('Ext.panel.Panel,{
title: record.get('name'),
html: [
"<b>Name:</b> " + record.get('name') +
"<b>Email:</b> " + record.get('email')
],
scrollable: true,
styleHtmlContent: true
})
)
and don't forget to use getItemlist().pop() when back button is clicked! In my app, the back button did not (or not always) remove the view on top of the stack. It gets even worse when adding loadmasks and ActionSheets.

switching between views in sencha touch

I have the following view code in sencha touch 2
Ext.define('WL.view.Categories', {
extend: 'Ext.Container',
requires: [
'Ext.SegmentedButton',
'WL.view.movie.List',
'Ext.form.Panel',
'Ext.plugin.ListPaging',
'Ext.TitleBar',
'WL.view.movie.SortBar',
'WL.view.movie.SearchBar'
],
xtype: 'categories',
config: {
layout: {
type: 'card',
animation: {
type: 'fade'
}
},
items: [
{
docked: 'top',
xtype: 'toolbar',
cls: 'small withBg',
title: 'Merchants',
items: [
/* {
xtype: 'segmentedbutton',
allowDepress: false,
items: [
/*
{
cls: 'movies',
iconCls: 'movies',
pressed: true
},
{
xtype: 'button',
cls: 'friends',
iconCls: 'friends'
}
]
},
*/
{ xtype: 'spacer' },
{
xtype: 'button',
cls: 'searchBtn',
iconCls: 'search',
align: 'right'
},
{
xtype: 'button',
cls: 'backBtn',
id: 'movieBackButton',
align: 'left'
}
/*
{
xtype: 'component',
cls: 'fbProfilePic',
id: 'fbProfilePic',
tpl: '<img src="https://graph.facebook.com/{profileId}/picture?type=square" />' // the img source can be later changed
}
*/
]
},
{
xtype:'list',
store: 'Merchants',
plugins: [
{ xclass: 'Ext.plugin.ListPaging' }
],
itemCls: 'expandedMovie',
itemHeight:114,
items: [
{ xtype: 'movieSortBar' , docked:'top'},
{ xtype: 'movieSearchBar' , docked:'top' , hidden:true},
{
xtype: 'container',
cls: 'promo',
itemId:'promo-container',
docked:'bottom',
html: '<span class="logo"></span>Brought to you by Sencha Touch 2.1 <button>Learn More</button>'
}
],
loadingText: null,
listeners: {
order: 'before',
select: function() {
return false;
},
itemtap: function(dataview, index, target, record, evt) {
var el = Ext.get(evt.target),
fireEvent;
if (el.dom.nodeName == 'B') el = el.parent();
WL.currentMovie = record;
if (el.hasCls('seen')) {
fireEvent = el.hasCls('selected') ? 'unSeen' : 'seen';
el.toggleCls('selected');
} else if (el.hasCls('want')) {
fireEvent = el.hasCls('selected') ? 'unWantToSee' : 'wantToSee';
el.toggleCls('selected');
} else if (el.hasCls('thumb') && el.hasCls('up')) {
fireEvent = el.hasCls('selected') ? 'unLike' : 'like';
el.toggleCls('selected');
} else if (el.hasCls('thumb') && el.hasCls('down')) {
fireEvent = el.hasCls('selected') ? 'unDislike' : 'dislike';
el.toggleCls('selected');
} else {
fireEvent = 'tapMovie';
}
if (fireEvent) {
this.fireEvent(fireEvent, record, el);
}
}
},
itemTpl: Ext.create('Ext.XTemplate',
'<div class="moreArrow"></div>',
'<div class="img"><img src="http://localhost/WL2/assets/rest/{image}" /></div>',
'<div class="meta">',
'<h3>{merchName}</h3>',
'<div class="actions">',
//'<div class="rating"><span>{% if (values.criticRating >= 0) { %}{criticRating}%{% } else { %}?{% } %}</span></div>',
'<button class="seen{[values.seen ? " selected" : ""]}">{action}</button>',
'{% if (values.seen) { %}',
'<button class="thumb up{[values.like ? " selected" : ""]}"><b></b></button>',
'<button class="thumb down{[values.dislike ? " selected" : ""]}"><b></b></button>',
'{% } else { %}',
'<button class="want{[values.wantToSee ? " selected" : ""]}">Want to Go There</button>',
'{% } %}',
'</div>',
'</div>'
)
} // end of the categories list
]
},
initialize: function() {
this.callParent();
// Enable the Tap event on the profile picture in the toolbar, so we can show a logout button
var profilePic = Ext.getCmp('fbProfilePic');
if (profilePic) {
profilePic.element.on('tap', function(e) {
profilePic.fireEvent('tap', profilePic, e);
});
}
}
});
I have defined xtype to my view, so I can reference it in my controller code
this is my controller code
Ext.define('WL.controller.Categories', {
extend: 'Ext.app.Controller',
config: {
refs: {
categories: 'categories',
List: 'list'
},
control: {
list: {
tapMovie: 'onMovieTap' // the function that will be created when a movie is tapped
}
}
},
slideLeftTransition: { type: 'slide', direction: 'left' },
slideRightTransition: { type: 'slide', direction: 'right' },
onMovieTap: function () {
Ext.Viewport.animateActiveItem(this.getCategories(),this.slideRightTransition);
}
});
my main problem is that the get function getCategories() in the controller doesn't work so I can navigate to my view with slide right effect, I think that my problem is in definin the xtype, can you give me a clue on defining the correct xtype, giving that I tried using alias:widget.categories but it didnt work as well.
Your config should look like this:
config: {
refs : {
categories : {
autoCreate: true,
selector: '#categories_itemId',
xtype: 'categories'
},
List : {
// do the same thing for 'List'
}
},
control: {
...
},
...
},
...
Notice that the selector is the itemIdof your view so give your categories view an itemId (you can see I just made one up).

how to move data from one page to another page in Senchatouch

I am developing one application in sencha touch, I am new to this technology
first see my code
View-->Main.js
Ext.define('DealsList.view.Main', {
extend: 'Ext.Container',
xtype: 'mainlist',
requires: [
'Ext.TitleBar',
'Ext.Toolbar'
],
config: {
fullscreen:true,
scrollable:false,
layout: {
// type:'fit'
},
items: [
{
xtype: 'toolbar',
//ui : 'green',
docked: 'top',
title: 'SampleDeals'
},
{
xtype:'formpanel',
fullscreen:false,
scrollable:false,
centered:true,
style: 'background-color: gray',
width:'90%',
height:'70%',
items:[
{
xtype:'selectfield',
name:'Grade',
label:'Grade',
options:[
{
text:'All',
value:'Agrade'
},
{
text:'Drink',
value:'Bgrade'
},
{
text:'Entertainment',
value:'cgrade'
},
{
text:'Food',
value:'Dgrade'
}
]
},
{
xtype:'searchfield',
id:'usernametext',
name:'ZipCode',
placeHolder:'ZipCode',
top:'25%'
},
{
xtype:'button',
text:'Gps On/Off',
id:'btnList',
ui:'action',
height:33,
top:'40%',
left:'5%',
right:'5%'
},
{
xtype:'selectfield',
name:'Grade',
label:'Grade',
top:'55%',
options:[
{
text:'2 miles',
value:'Agrade'
},
{
text:'5 miles',
value:'Bgrade'
},
{
text:'10 miles',
value:'cgrade'
},
{
text:'15+ miles',
value:'Dgrade'
}
]
},
{
xtype:'button',
text:'My Favorites',
id:'favbutton',
ui:'action',
width:150,
height:33,
top:'75%',
left:'5%'
}
,{
xtype:'button',
text:'Go',
id:'gobutton',
ui:'action',
width:100,
height:33,
top:'75%',
right:'5%',
handler:this.regButton,
scope:this
}
]
}
]
}
});
view-->ListPage.js
Ext.define('DealsList.view.ListPage', {
extend: 'Ext.List',
xtype: 'listPage',
requires:['Ext.data.Store','Ext.dataview.List','Ext.data.proxy.JsonP'],
config: {
// itemTpl: '<table><tr><td><img src="{imageUrl}" width="70%" height="70%"/></td><td> </td><td><div class=\"list-item-firstname\">{firstName}</div><div class=\"list-item-lastname\">{lastName}</div></td></tr></table>',
itemTpl: ' <table><tr>' +
'<td><img src="{logopath}"/></td>' +
'<td> </td>' +
'<td><div><h3>{subcategoryname}</h3></div>' +
'<div><h1>{specialinfo}</h1></div>' +
'<div>Price:{originalprice}</div>' +
'<div><h1>{fromdate}</h1></div>' +
'</td></tr></table>',
store: 'DetailStore',
onItemDisclosure: true,
items:
[
{
xtype:'toolbar',
title:'SampleDeals',
docked:'top',
items:[
{
xtype:'button',
id:'backbutton',
ui:'back',
text:'back'
}
]
}
]
}
});
view-->DealsDescription.js
Ext.define('DealsList.view.DealsDescription', {
extend: 'Ext.Container',
xtype: 'dealsdescription',
requires:['Ext.Toolbar','Ext.field.Email','Ext.field.Password'],
config: {
fullscreen:true,
scrollable:false,
layout: {
// type:'fit'
},
items: [
{
xtype:'toolbar',
docked:'top',
title:'SampleDeals',
items:[
{
xtype:'button',
id:'backbutton',
ui:'back',
text:'back'
}
]
},
{
xtype:'label',
html: '<h1>{subcategoryname}</h1>'
//html: ["test test"].join("") '',
},
{
xtype:'label',
html: '<h1>{dealtimestampfrom}</h1>'
//html: ["test test"].join("") '',
},
{
xtype:'label',
html: '<h1>{specialinfo}</h1>'
//html: ["test test"].join("") '',
},
{
xtype:'label',
html: '<h1>{originalprice}</h1>'
//html: ["test test"].join("") '',
},
{
xtype:'button',
text:'Button',
id:'xxxbutton',
ui:'action',
top:'30%',
left:'35%',
right:'35%',
handler:this.saveButton
}
]
}
});
Store-->DetailStore.js
Ext.define('DealsList.store.DetailStore', {
extend: 'Ext.data.Store',
config: {
model: 'DealsList.model.DetailModel',
autoLoad: true,
remoteFilter: true,
//sorters: 'leadid',
grouper: {
groupFn: function(record) {
// return record.get('user_id')[0];
return record.get('dealtimestampfrom')[0];
}
},
proxy: {
type: 'ajax',
//url: 'http://113.193.181.53:8081/Test/chat/index.php/chat/onlineusers',
url:'http://www.nomdeal.com/services/getbusinessoffers?catid=All&subcatid=All&lat=17.4418224&lng=78.4752594&dist=1000&userid=100&zipcode=&pagesize=1',
//headers: {'Authorization': 'Basic GVU0IXZ6cFGzczE='},
reader: {
type: 'json',
model: 'DealsList.model.DetailModel',
// rootProperty: 'online-users'
record:'businessholder',
rootProperty: 'specialinfo'
// rootProperty:''
}
}
}
});
Model-->DetailModel.js
Ext.define('DealsList.model.DetailModel', {
extend: 'Ext.data.Model',
config: {
fields: [
{name: "dealtimestampfrom", type: "string"},
{name: "dealtimestampto", type: "string"},
{name: "subcategoryname", type: "string"},
{name: "specialinfo", type: "string"},
{name: "originalprice", type: "string"},
{name: "logopath", type: "string"},
{name: "fromdate", type: "string"}
]
}
});
Controller-->dealscontroller.js
Ext.define('DealsList.controller.dealscontroller', {
extend: 'Ext.app.Controller',
config: {
refs: {
BtnList:'#btnList',
listPage:'listPage',
mainpage:'mainlist',
backHome:'#backbutton',
goButton:'#gobutton',
DealsDescriptionpage:'dealsdescription'
},
control: {
goButton:
{
tap:'mainCategories'
},
backHome:
{
tap:'backToHome'
},
listPage:
{
itemtap: 'ListItemSelect'
}
}
},
// Transitions
slideLeftTransition: { type: 'slide', direction: 'left' },
slideRightTransition: { type: 'slide', direction: 'right' },
//called when the Application is launched, remove if not needed
launch: function(app) {
},
mainCategories:function()
{
//alert('sf');
Ext.Viewport.animateActiveItem(this.getListPage(), this.slideLeftTransition);
},
backToHome:function()
{
Ext.Viewport.animateActiveItem(this.getMainpage(), this.slideLeftTransition);
},
ListItemSelect : function (list, index, element, record)
{
Ext.Msg.alert('Alert',record.get('subcategoryname'));
Ext.Viewport.animateActiveItem(this.getDealsDescriptionpage(), this.slideLeftTransition);
}
});
app.js
//<debug>
Ext.Loader.setPath({
'Ext': 'touch/src',
'DealsList': 'app'
});
//</debug>
Ext.application({
controllers: ["dealscontroller"],
name: 'DealsList',
requires: [
'Ext.MessageBox'
],
views: ['Main','ListPage','DealsDescription'],
stores:['DetailStore'],
models:['DetailModel'],
icon: {
'57': 'resources/icons/Icon.png',
'72': 'resources/icons/Icon~ipad.png',
'114': 'resources/icons/Icon#2x.png',
'144': 'resources/icons/Icon~ipad#2x.png'
},
isIconPrecomposed: true,
startupImage: {
'320x460': 'resources/startup/320x460.jpg',
'640x920': 'resources/startup/640x920.png',
'768x1004': 'resources/startup/768x1004.png',
'748x1024': 'resources/startup/748x1024.png',
'1536x2008': 'resources/startup/1536x2008.png',
'1496x2048': 'resources/startup/1496x2048.png'
},
launch: function()
{
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
var mainPage = {
xtype:'mainlist'
};
var listpage = {
xtype:'listPage'
};
var dealsdescription = {
xtype:'dealsdescription'
};
// Initialize the main view
Ext.Viewport.add(([mainPage,listpage,dealsdescription]));
},
onUpdated: function() {
Ext.Msg.confirm(
"Application Update",
"This application has just successfully been updated to the latest version. Reload now?",
function(buttonId) {
if (buttonId === 'yes') {
window.location.reload();
}
}
);
}
});
In my app's first screen I have a go button. When I click on this button it displays a list(listpage.js) my problem is, when I click on a listitem data is not moving to the nextpage(DealsDescription.js). My requrement is that the data moves to next page and is appended to that xtype:label(DealsDescription.js screen)
Most of us set up a one page application. So you switch cards (or tabs or so...) in staid of refreshing the page. This way you can always get to the data though javascript. Navigating up or down the component tree.
Up:
mycomponent.up() //go up one level
mycomponent.up(selector) //go up till you reach the component meeting the criteria
Down:
mycomponent.query(someComponentQuery) //go down and find all components meeting the criteria
mycomponent.getComponent(componentId) //get the (direct) child with given Id
If you do want to load a new page you need a whole new app.. So you could use session or local storage to transfer data between pages. (use a sessionstorageProxy or localstorageProxy on your store/model).
Basically you have to declare a data holder variable in view's config and while creating this view you can initialize it with whatever data you want.
var myView = Ext.create('DealsList.view.DealsDescription', {
rec : someData //this would contain all data
});
Then in initialize you can access this rec like this:
var data = this.config.rec;
then you can create all internal components and add to this view's container.
var items = [{
xtype:'toolbar',
docked:'top',
title:'SampleDeals',
items:[
{
xtype:'button',
id:'backbutton',
ui:'back',
text:'back'
}
]
},
{
xtype:'label',
html: '<h1>'+data.subcategoryname+'</h1>'
}];
this.setItems(items);

Sencha Touch Ext.TabPanel handler

I did a lot of reading but i can't figure this out.
This app uses Sencha Touch 2.0
My 'app' has a segmented button
xtype: 'segmentedbutton'
With this item
{
text: 'Blog',
scope: this,
handler: this.makeYqlRequest
}
This is what it does
blog: {
query: "select * from rss where url='http://feeds.feedburner.com/extblog' limit 5",
tpl: Ext.create('Ext.XTemplate', [
'<tpl if="item">',
'<tpl for="item">',
'<div class="blog-post">',
'<h3>{title}</h3>',
'<p>{description}</p>',
'</div>',
'</tpl>',
'</tpl>'
])
}
This works wel but now i want to use the Ext.TabPanel
And i have this item
{
title: 'Blog',
iconCls: 'home',
html: 'Blog Screen'
}
How can i get the handler from the segmented button to work with the Ext.TabPanel?
I played a little with a listener but i can't get it to work.
Can someone explain this a little more to me?
Thank you!
You will need to get a reference to your TabPanel and call the [setActiveItem](http://docs.sencha.com/touch/2-0/#!/api/Ext.Container-method-setActiveItem), passing the view you want to make active, or the index of that view.
Simple example (viewable here):
Ext.setup({
onReady: function() {
var tabPanel = Ext.create('Ext.tab.Panel', {
fullscreen: true,
items: [
{
title: 'Home',
items: [
{
xtype: 'toolbar',
items: [
{
xtype: 'segmentedbutton',
items: [
{
text: 'home'
},
{
text: 'blog',
handler: function() {
// Using an index
tabPanel.setActiveItem(1);
}
},
{
text: 'about',
handler: function() {
// Using a reference
var about = tabPanel.down('#about');
tabPanel.setActiveItem(about);
}
}
]
}
]
},
{
html: 'tap one of the above buttons to change the active tab.'
}
]
},
{
title: 'Blog',
html: 'blog'
},
{
title: 'About',
itemId: 'about',
items: [
{
xtype: 'toolbar',
docked: 'top',
items: [
{
text: 'Go to home',
handler: function() {
// using the index
tabPanel.setActiveItem(0);
}
}
]
}
]
}
]
});
}
});

Resources