I am trying to get my Ext.Menu with a list to respond to my event in my Controller.
I am not sure why I can not get a response from the list in the Ext.Menu.
Could someone please tell me what I am missing.
Thanks
Ext.define('Pear.view.Main', {
extend: 'Ext.Container',
xtype: 'main',
requires: [
'Ext.Menu'
],
config: {
layout: {
type: 'card'
},
items: [
{
xtype: 'toolbar',
docked: 'top',
title: 'Sliding Menu',
items: [
{
xtype: 'button',
id: 'listButton',
iconCls: 'list',
ui: 'plain',
handler: function(){
if(Ext.Viewport.getMenus().left.isHidden()){
Ext.Viewport.showMenu('left');
}
else
{
Ext.Viewport.hideMenu('left');
}
}
}
]
}
]
},
initialize: function(){
Ext.Viewport.setMenu(this.createMenu(),{
side: 'left',
reveal: true
});
},
createMenu: function(){
var menu = Ext.create('Ext.Menu', {
layout: 'fit',
width: 220,
xtype:'menuList',
items: [{
xtype: 'titlebar',
title: 'Side menu'
}, {
xtype: 'list',
itemTpl: '{title}',
//store: 'Beginning',
data: [{
title: 'Menu item 1'
}, {
title: 'Menu item 2'
},
{
title: 'Menu item 3'
}, {
title: 'Menu item 4'
}]
}]
});
return menu;
}
});
My Controller
Ext.define( 'Pear.controller.Main', {
extend:'Ext.app.Controller',
config:{
refs: {
Main: 'main',
},
control: {
'main list ':{
itemtap:function(list,index,target,record){
console.log("Option 2 Tapped");
}
},
},
}
});
Your list reference is wrong. Best way to get the reference of an item is to set a config name property to that item like this:-
{
xtype: 'list',
itemTpl: '{title}',
name: 'menu_list', // add this property to get the reference
data: [{
title: 'Menu item 1'
}, {
title: 'Menu item 2'
},
{
title: 'Menu item 3'
}, {
title: 'Menu item 4'
}]
}
Add the control in the controller:-
Ext.define( 'Pear.controller.Main', {
extend:'Ext.app.Controller',
config:{
refs: {
menuList : "list[name='menu_list']"
},
control: {
menuList : {
itemtap: function(list,index,target,record){
console.log("Option 2 Tapped");
}
}
}
}
});
I'm working on a Sencha Touch App. This App have 3 lists: clients, tasks and asignations. Each one has its own model and store. The 3rd one, asignations lists, is an asignations of a task to a client, so that list must show which task and client are asignated.
Models
Ext.define('TasksApp.model.Asignation',{
extend: 'Ext.data.Model',
config: {
idProperty: 'id',
fields: [
{name: 'asignID'},
{name: 'nombreasignacion', type: 'string'},
{name: 'clienteasignacion', type: 'string'},
{name: 'tareaasignacion', type: 'string'},
{name: 'finasignacion', type: 'date'},
{name: 'obsasignacion', type: 'string'},
{name: 'recordatorio', type: 'string'},
{name: 'estadoasignacion', type: 'string'}
],
}
});
Ext.define('TasksApp.model.Client',{
extend: 'Ext.data.Model',
config: {
idProperty: 'id',
fields: [
{name: 'clientID'},
{name: 'nombrecliente', type: 'string'},
{name: 'obscliente', type: 'string'},
{name: 'tlfcliente', type: 'int'},
{name: 'emailcliente', type: 'string'},
{name: 'urlcliente', type: 'string'},
{name: 'asigncliente', type: 'int', defaultValue: 0}
],
}
});
Ext.define('TasksApp.model.Task',{
extend: 'Ext.data.Model',
config:
{
idProperty: 'id',
fields: [
{name: 'tareaID'},
{name: 'nombretarea', type: 'string'},
{name: 'descripciontarea', type: 'string'},
{name: 'tdesarrollotarea', type: 'int'},
{name: 'asigntarea', type: 'int', defaultValue: 0}
],
}
});
Asignations List View + Asignation Template
var plantillaAsignacion = new Ext.XTemplate(
'<tpl for=".">',
'<div class="tplAsignacion">',
'<div class="asignacionCabecera">',
'<DIV ALIGN=center><B><I>{nombreasignacion}</i></B></DIV>',
'</div>',
'<div class="clienteCuerpo">',
'<div class="asignacionImagen" style= "float: left;"><img src="resources/images/asign_icon.png"/></div>',
'<ol>',
'<li><pre> Cliente: {clienteasignacion}</a></pre></li>',
'<li><pre> Tarea: {tareaasignacion}</pre></li>',
'<li><pre> Finalización: {finasignacion:date("d/m/Y")}<div align="right">Estado: {estadoasignacion} <span class="status {estadoasignacion}"></span> </pre></li>', //("l, F d, Y")("d/m/Y")
'</ol>',
'</div>',
'</div>',
'</tpl>'
);
Ext.define('TasksApp.view.AsignationsList', {
extend: 'Ext.Container',
requires: [ 'Ext.TitleBar', 'Ext.dataview.List' ],
alias: 'widget.asignationslistview',
config: {
layout: {
type: 'fit',
},
items:
[
{
xtype: 'titlebar',
title: 'Lista de asignaciones',
docked: 'top',
items:
[
{
xtype: 'button',
iconCls: 'add',
ui: 'action',
itemId: 'newButton',
align: 'right'
},{
xtype: 'button',
text: 'Clientes',
ui: 'action',
itemId: 'goToClients', iconCls: 'team',
align: 'left'
},
{
xtype: 'button',
text: 'Tareas',
ui: 'action',
itemId: 'goToTasks', iconCls: 'bookmarks',
align: 'left'
},
]
},
{
xtype: 'list',
store: 'Asignations',
itemId: 'asignationsList',
cls: 'estado-asignacion',
loadingText: 'Cargando Asignaciones...',
emptyText: 'No hay asignaciones actualmente',
onItemDisclosure: true,
//grouped: true,
itemTpl: plantillaAsignacion,
}
],
listeners:
[
{
delegate: '#newButton',
event: 'tap',
fn: 'onNewButtonTap'
},
{
delegate: '#asignationsList',
event: 'disclose',
fn: 'onAsignationsListDisclose'
},
{
delegate: '#goToClients',
event: 'tap',
fn: 'onGoToClients'
},
{
delegate: '#goToTasks',
event: 'tap',
fn: 'onGoToTasks'
}
]
},
onNewButtonTap: function () {
console.log('newAsignationCommand');
this.fireEvent('newAsignationCommand', this);
},
onAsignationsListDisclose: function (list, record, target, index, evt, options) {
console.log('editAsignationCommand');
this.fireEvent('editAsignationCommand', this, record);
},
onGoToClients: function () {
console.log ('goToClientsCommand');
this.fireEvent('goToClientsCommand', this);
},
onGoToTasks: function () {
console.log ('goToTasksCommand');
this.fireEvent('goToTasksCommand', this);
}
});
Asignation Editor View ( form of the asignation )
Ext.define('TasksApp.view.AsignationEditor', {
extend: 'Ext.form.Panel',
requires: [
'Ext.TitleBar', 'Ext.form.FieldSet', 'Ext.field.Text','Ext.field.Select', 'Ext.field.DatePicker', 'Ext.field.TextArea','Ext.form.Panel'
],
alias: 'widget.asignationeditorview',
config: {
scrollable: 'vertical',
items:
[
{
xtype: 'titlebar',
docked: 'top',
title: 'Editar Asignación',
items:
[
{
xtype: 'button',
ui: 'back',
text: 'Volver',
itemId: 'backButton',
align: 'left'
},
{
xtype: 'button',
ui: 'action',
text: 'Guardar',
itemId: 'saveButton',
align: 'right'
}
]
},
{
xtype: 'toolbar',
docked: 'bottom',
items: [
{
xtype: 'button',
iconCls: 'trash',
iconMask: true,
itemId: 'deleteButton'
}
]
},
{
xtype: 'fieldset',
items:
[
{
xtype: 'textfield',
name: 'nombreasignacion',
label: 'Nombre',
required: true,
autoCapitalize: true,
placeHolder: 'Nombre de la asignación...'
},
{
xtype: 'selectfield',
name: 'clienteasignacion',
label: 'Cliente',
valueField: 'clientID',
displayField: 'nombrecliente',
store: 'Clients',
autoSelect: false,
placeHolder: 'Seleccione un cliente...',
required: true,
},
{
xtype: 'selectfield',
name: 'tareaasignacion',
label: 'Tarea',
valueField: 'tareaID',
displayField: 'nombretarea',
store: 'Tasks',
autoSelect: false,
placeHolder: 'Seleccione una tarea...',
required: true,
},
{
xtype: 'datepickerfield',
name: 'finasignacion',
label: 'Vencimiento',
dateFormat: 'd/m/Y',
value: (new Date()),
picker:
{
yearFrom: new Date().getFullYear(),
yearTo: 2040,
slotOrder: [ 'day', 'month', 'year' ]
}
},
{
xtype: 'textareafield',
name: 'obsasignacion',
label: 'Observaciones',
autoCapitalize: true,
autoCorrect: true,
placeHolder: 'Observaciones de la asignación...',
maxRows: 5
},
{
xtype: 'selectfield',
name: 'recordatorio',
label: 'Recordatorio',
autoSelect: true,
placeHolder: 'Seleccione el método recordatorio...',
required: true,
options:
[
{
text: 'Ninguno',
value: 0
},
{
text: 'eMail',
value: 2
},
{
text: 'SMS',
value: 1
},
{
text: 'Notificación',
value: 3
}
]
},
{
xtype: 'selectfield',
name: 'estadoasignacion',
label: 'Estado',
autoSelect: true,
placeHolder: 'Seleccione el estado...',
required: true,
options:
[
{
text: 'Activa',
value: 'Activa'
},
{
text: 'Caducada',
value: 'Caducada'
},
{
text: 'Cancelada',
value: 'Cancelada'
},
{
text: 'Realizada',
value: 'Realizada'
}
]
},
]
}
],
listeners: [
{
delegate: '#saveButton',
event: 'tap',
fn: 'onSaveButtonTap'
},
{
delegate: '#deleteButton',
event: 'tap',
fn: 'onDeleteButtonTap'
},
{
delegate: '#backButton',
event: 'tap',
fn: 'onBackButtonTap'
}
]
},
onSaveButtonTap: function () {
console.log('saveAsignationCommand');
this.fireEvent('saveAsignationCommand', this);
},
onDeleteButtonTap: function () {
console.log('deleteAsignationCommand');
this.fireEvent('deleteAsignationCommand', this);
},
onBackButtonTap: function () {
console.log('backToHomeCommand');
this.fireEvent('backToHomeCommand', this);
}
});
Asignation Controller
Ext.define('TasksApp.controller.Asignations', {
extend: 'Ext.app.Controller',
config: {
refs: {
asignationsListView: 'asignationslistview',
asignationEditorView: 'asignationeditorview'
},
control: {
asignationsListView: {
newAsignationCommand: 'onNewAsignationCommand',
editAsignationCommand: 'onEditAsignationCommand'
},
asignationEditorView: {
saveAsignationCommand: 'onSaveAsignationCommand',
deleteAsignationCommand: 'onDeleteAsignationCommand',
backToHomeCommand: 'onBackToHomeCommand'
}
}
},
getSlideLeftTransition: function () {
return { type: 'slide', direction: 'left' };
},
getSlideRightTransition: function () {
return { type: 'slide', direction: 'right' };
},
getRandomInt: function (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
},
activateAsignationEditor: function (record) {
var asignationEditorView = this.getAsignationEditorView();
asignationEditorView.setRecord(record); // load() is deprecated.
Ext.Viewport.animateActiveItem(asignationEditorView, this.getSlideLeftTransition());
},
activateAsignationsList: function () {
Ext.Viewport.animateActiveItem(this.getAsignationsListView(), this.getSlideRightTransition());
},
onNewAsignationCommand: function () {
console.log('onNewAsignationCommand');
var now = new Date();
var asignationId = (now.getTime()).toString() + (this.getRandomInt(0, 100)).toString();
var newAsignation = Ext.create('TasksApp.model.Asignation', {
id: asignationId,
nombreasignacion: '',
clienteasignacion: '',
tareaasignacion: '',
finasignacion: '',
obsasignacion: '',
recordatorio: '',
estadoasignacion: ''
});
this.activateAsignationEditor(newAsignation);
},
onEditAsignationCommand: function (list, record) {
console.log('onEditAsignationCommand');
this.activateAsignationEditor(record);
},
onSaveAsignationCommand: function () {
console.log('onSaveAsignationCommand');
var asignationEditorView = this.getAsignationEditorView();
var currentAsignation = asignationEditorView.getRecord();
var newValues = asignationEditorView.getValues();
currentAsignation.set('nombreasignacion', newValues.nombreasignacion);
currentAsignation.set('clienteasignacion.nombrecliente', newValues.clienteasignacion);
currentAsignation.set('tareaasignacion.nombretarea', newValues.tareaasignacion);
currentAsignation.set('finasignacion', newValues.finasignacion);
currentAsignation.set('obsasignacion', newValues.obsasignacion);
currentAsignation.set('recordatorio', newValues.recordatorio);
currentAsignation.set('estadoasignacion', newValues.estadoasignacion);
var asignationsStore = Ext.getStore('Asignations');
if (null == asignationsStore.findRecord('id', currentAsignation.data.id)) {
asignationsStore.add(currentAsignation);
}
asignationsStore.sync();
asignationsStore.sort([{ property: 'dateCreated', direction: 'DESC'}]);
this.activateAsignationsList();
},
onDeleteAsignationCommand: function () {
console.log('onDeleteAsignationCommand');
var asignationEditorView = this.getAsignationEditorView();
var currentAsignation = asignationEditorView.getRecord();
var asignationsStore = Ext.getStore('Asignations');
asignationsStore.remove(currentAsignation);
asignationsStore.sync();
this.activateAsignationsList();
},
onBackToHomeCommand: function () {
console.log('onBackToHomeCommand');
this.activateAsignationsList();
},
launch: function () {
this.callParent(arguments);
var asignationsStore = Ext.getStore('Asignations');
asignationsStore.load();
console.log('launch');
},
init: function () {
this.callParent(arguments);
console.log('init');
}
});
I want the asignations list to show the client name ( nombrecliente ) and the task name ( nombretarea ), but it shows nothing at all. I don't know how to refer to this values so the list shows them. I tried to modify the asignations controller, the selectfield int the asignation editor ( form ) and the asignations template, but I simply don't know how this works and what I have to do to show that values ( if they are saved in the asignations store at this moment via selectfield, or am I doing anything wrong? )
I would appreciate any help. Thank you in advance.
PS: sorry for my English, it's not my native language :)
Please create array in the key value pair with the key name as your model field and then set that data into your asign Asignations store like:
Asignations.setdata({fieldName:"value"});
I have made a sencha touch app. The app contains list. When I run the app in my computer browser, the list will appear properly. But when I run it on android mobile browser or as a android mobile app the list does not appear. The code as follows:
Model:
Ext.define('Proximity.model.CandidatebestlistModel', {
extend: 'Ext.data.Model',
config: {
store: 'Proximity.store.CandidatebestStore',
fields: [{
name: 'id',
type: 'int'
},
{
name: 'name',
type: 'string'
},
{
name: 'img',
type: 'string'
},
{
name: 'designation',
type: 'string'
},
{
name: 'summary',
type: 'string'
},
{
name: 'experience',
type: 'string'
},
{
name: 'industry',
type: 'string'
},
{
name: 'functionnml',
type: 'string'
},
{
name: 'role',
type: 'string'
}
],
proxy: {
type: 'ajax',
url: Proximity.app.baseUrl + '/index.php/candidate/getcandidatebest',
withCredentials: false,
useDefaultXhrHeader: false,
extraParams: {
"id": localStorage.getItem('id')
},
reader: {
filters: [
Ext.create('Ext.util.Filter', {
property: 'ind_id',
property: 'fun_id',
property: 'role_id'
})
]
}
}
}
});
Store:
Ext.define('Proximity.store.CandidatebestStore', {
extend: 'Ext.data.Store',
alias: 'store.candidatebeststore',
config: {
model: 'Proximity.model.CandidatebestlistModel',
autoLoad: true,
remoteFilter: true,
storeId: 'candidatebeststore'
}
});
View:
{
width: Ext.os.deviceType == 'Phone' ? null : '100%',
height: Ext.os.deviceType == 'Phone' ? null : '100%',
xtype: 'list',
itemId: 'list',
store: 'candidatebeststore',
masked: {
xtype: 'loadmask',
message: 'Please wait... '
},
emptyText: 'No List Item Found',
disableSelection: false,
itemTpl: '{name}
'+
'{designation} {
summary
} {
experience
}
Years Experience '+
'',
listeners: {
select: function(view, record) {
Proximity.app.getController('CandidatelistController').onDetailsview(record.get('id'));
}
}
}
For additional information:-- I place this list inside the tab panel. So Please give me some solution of this problem.
Thank You.
In the following line of codes
width: Ext.os.deviceType == 'Phone' ? null : '100%',
height: Ext.os.deviceType == 'Phone' ? null : '100%',
replace null with '100%'.
I have created FIXTURES using ember-model, but i am not able to use following node on template
"logged_in": {
"id" : "1",
"logged": true,
"username": "sac1245",
"account_id": "4214"
}
I have implemented belongsTo relation for this node but it throwing one error : Uncaught Error: Ember.Adapter must implement findQuery
Here i have listed my model code :
Astcart.Application = Ember.Model.extend({
name: Ember.attr(),
logo_url : Ember.attr(),
list: Ember.hasMany('Astcart.List', {key: 'list', embedded: true}),
logged_in: Ember.belongsTo('Astcart.Logged_in', {key: 'logged_in'})
});
Astcart.List = Ember.Model.extend({
name: Ember.attr()
});
Astcart.Logged_in = Ember.Model.extend({
id: Ember.attr(),
logged: Ember.attr(),
username: Ember.attr(),
account_id: Ember.attr()
});
Astcart.Application.adapter = Ember.FixtureAdapter.create();
Astcart.Application.FIXTURES = [
{
"id" : "1",
"logo_url": "img/logo.jpg",
"logged_in": {
"id" : "1",
"logged": true,
"username": "sac1245",
"account_id": "4214"
},
"name": "gau",
"list": [
{
"id" : "1",
"name": "amit"
},
{
"id" : "2",
"name": "amit1"
}
]
}
];
Template code :
{{#each item in model}}
{{item.name}}
{{item.logged_in.logged}}
{{/each}}
Router code :
Astcart.ApplicationRoute = Ember.Route.extend({
model: function() {
return Astcart.Application.find();
}
});
Can any one show me how to access data of above node in template?
Your current fixture have the logged_in data embedded:
Astcart.Application.FIXTURES=[
{
...
"logged_in": {
"id": "1",
"logged": true,
"username": "sac1245",
"account_id": "4214"
},
...
}
];
So the logged_in property mapping need the parameter embedded: true, to be able to find this data, as follow:
Astcart.Application = Ember.Model.extend({
...
logged_in: Ember.belongsTo('Astcart.Logged_in', {key: 'logged_in', embedded: true })
});
Without this it will try to query for the Astcart.Logged_in:
Astcart.Logged_in.find(1)
and because it doesn't have an adapter, will fail with the exception: Uncaught Error: Ember.Adapter must implement findQuery
You can see this working in that fiddle http://jsfiddle.net/marciojunior/8zjsh/
Hi I don't understand why I don't see my list in tab3...
This is my code...
I add one record in myStore but I don't see the list...
Thanks in advance!
var mainForm ;
var mainFormPanel={};
var addToXml=function (values){};
var htmlTemplate='<p>{b}</p><p>{m}</p><p>{f}</p>';
var template = new Ext.Template(htmlTemplate);
var myStore = Ext.create('Ext.data.Store', {
storeId: 'MyStore',
fields: [
{name: 'id', type: 'string'},
{name: 'c', type: 'string'},
{name: 'd', type: 'string'},
{name: 'q', type: 'string'},
{name: 'n', type: 'string'}
]
}); // create()
myStore.add({id:"id",c:"222",d:"333",q:"444",n:"555"});
var listpanel;
var config={
glossOnIcon: false,
autoMaximize: false,
icon: {
57: 'lib/sencha-touch/resources/icons/icon.png',
72: 'lib/sencha-touch/resources/icons/icon#72.png',
114: 'lib/sencha-touch/resources/icons/icon#2x.png',
144: 'lib/sencha-touch/resources/icons/icon#114.png'
},
phoneStartupScreen: 'lib/sencha-touch/resources/loading/Homescreen.jpg',
tabletStartupScreen: 'lib/sencha-touch/resources/loading/Homescreen~ipad.jpg',
//next we require any components we are using in our application.
requires: [
'Ext.tab.Panel',
'Ext.form.*',
'Ext.field.*',
'Ext.Button',
'Ext.data.Store'
],
launch: function() {
var list= Ext.create("Ext.NavigationView",{
xtype: 'list',
itemTpl: 'D:{id} - C:{c}',
store: myStore,
fullscreen: true,
layout:'fit',
title:'listtitle',
onItemDisclosure: function (record, btn, index) {
view.push({
xtype: 'panel',
renderTo: document.body,
layout:'fit',
title: 'second view',
html: 'second view',
styleHtmlContent: true
});
}
});
var myTitle= {
xtype: 'titlebar',
id: 'myTitle',
docked: 'top',
title: 'mytitle'//,
};
var myMean={
xtype: 'titlebar',
id: 'myMean',
docked: 'bottom',
title: 'myMean'
};
listpanel = new Ext.Panel({
xtype:'panel',
header:true,
layout: 'fit', // important to make layout as 'fit'
id:'listpanel',
title:'listpanel',
items: [myTitle,myMean,list]
});
var view = Ext.create("Ext.NavigationView", {
layout:'fit',
id:'view',
items: [listpanel]
});
Ext.Viewport.add({
xtype: 'tabpanel',
tabBarPosition: 'bottom',
items: [
{
title: '1-tab',
layout:'fit',
iconCls: 'home',
html:'tab1',
cls: 'card1'
},
{
title: '2-tab',
layout:'fit',
iconCls: 'download',
html:'tab2',
cls: 'card2'
},
{
title: '3-tab',
layout:'fit',
iconCls: 'home',
items: [view],
cls: 'card3'
},
{
title: '4-tabs',
layout:'fit',
iconCls: 'home',
html: '4-tab',
cls: 'card4'
}
]
});
}
};
Ext.application(config);
have you tried setting flex: 1, layout: 'vbox' instead of layout: 'fit'?
Solved deleting fullscreen: true,layout:'fit' in var list.