Sencha Touch make Dataview dynamic elements draggable - sencha-touch

I have a dataview that is populated using a store and template so the process is dynamic. I then want to make each of the container Divs (see template) draggable and use the following code. I would have expected just the container divs(image + name) to be draggable but instead the whole DataView is draggable. Was wondering what i am doing wrong?
Ext.define('MyApp.view.allImages', { extend: 'Ext.dataview.DataView',
xtype: 'cams',
requires: [
'MyApp.store.images'
],
config: {
title: 'Test',
store: 'images',
baseCls: 'camera-list',
itemTpl: [
'<div id="camimage">',
'<div class="image" style="background-image:url({fullimage})"></div>',
'<div class="name">{address}</div>',
'</div>'
].join(''),
records: null,
items: [
{
xtype: 'toolbar',
docked: 'top',
title: 'Gainesville'
},
{
xtype: 'toolbar',
docked: 'bottom',
items: [
{
xtype: 'button',
text: 'Path1'
},
{
xtype: 'button',
text: 'Path2'
},
{
xtype: 'button',
text: 'Path3'
}
]
}
]
},
initialize: function () {
this.callParent(arguments);
//get the divs that we want to make draggable
var images = this.element.select("div[id='camimage']");
Ext.each(images.elements, function (imageElement) {
imageElement.draggable = true;
});
}

It is a problem with the life cicle of the component, you must wait until the dataview has rendered, so you can access the elements.
initialize: function () {
this.callParent(arguments);
var me = this;
//get the divs that we want to make draggable
//
setTimeout(function (argument) {
var images = me.element.select("div.image-dataview-item");
Ext.each(images.elements, function (imageElement) {
var draggable = new Ext.util.Draggable({
element: imageElement,
listeners: {
dragstart: function(self, e, startX, startY) {
console.log("test dragStart[" + startX + ":" + startY + "]");
},
drag: function(self, e, newX, newY) {
console.log("test drag[" + newX + ":" + newY + "]");
},
dragend: function(self, e, endX, endY) {
console.log("test dragend[" + endX + ":" + endY + "]");
}
}
});
draggable.setConstraint({
min: { x: -Infinity, y: -Infinity },
max: { x: Infinity, y: Infinity }
});
draggable.group = 'base';// Default group for droppable
draggable.revert = true;
});
},1000);
}

You are using a hardcoded element ID on an item template. You will end up with multiple elements with the same ID. You should change camimage from an id to a class, or if you are really attached to your ID use the record identifier so each div ID is unique.

Related

Sencha Touch 2.2.1 Carousel not inizialized

I'm back on the project of catalogue viewer app, and after updating to the last sencha release, I have the same problem I had a couple of month ago...the carousel don't recognize the onTap event or, it won't load correctly.
The app is quite simple, the structure is the following:
company name
list of catalogues
detailcard with the catalogue pages (3 per row)
carousel starting from the page tapped
The fact that when I use the app NOT compiled with sencha cmd, it work very smoothly, and problemless, but when I build the app (also production and packaging) with sencha cmd, it won't work.
The dataview show all the image, and when I click one of them, it pop-up the carousel, but empty. I tried to debug, and it won't do the initialize, but why only in the build version?
The code that I use is the following:
Ext.define('CIAM_app.view.Cataloghi', {
extend: 'Ext.NestedList',
xtype: 'cataloghi',
requires: ['Ext.data.TreeStore', 'Ext.carousel.Carousel'],
fullscreen: true,
config: {
iconCls: 'doc',
iconMask: true,
title: 'Cataloghi',
styleHtmlContent: true,
store: 'lista_cataloghiStore',
variableHeights: true,
listConfig: {
itemTpl: '<tpl if="leaf == false"><img src="{icon}" alt="{text}" class="cataloghi_img" /></tpl><tpl if="leaf == true"><p class="cataloghi_p">{text}</p></tpl>',
},
listeners: {
leafitemtap: function(nestedList, list, index, target, record) {
var detailCard = nestedList.getDetailCard();
var pagina = record.get('immagini_catalogo');
var n = record.get('pagine_catalogo');
items = [];
if (detailCard.getData() != null) {
detailCard.getStore().removeAll(true, true);
}
for (i = 1; i <= n; i++) {
items.push({
src: 'gallery/' + pagina + '/' + i + '.jpg',
});
}
detailCard.setData(items);
detailCard.refresh();
},
},
detailCard: {
xtype: 'dataview',
itemTpl: '<img src="{src}">',
cls: 'immagine_catalogo',
listeners: {
itemtap: function(dataView, index, target, record, e, eOpts) {
Ext.Viewport.add({
xtype: 'carousel',
extend: 'Ext.Carousel',
defaultType: 'image',
initialize: function() {
this.setItems(dataView.getData());
this.setActiveItem(index);
this.callParent();
this.element.on('tap', this.onTap, this);
},
onTap: function(e, t) {
this.fireEvent('tap', this, e, t);
this.hide();
},
style: {
'background': 'rgba(206,203,203,0.87)'
},
indicator: false,
width: '100%',
height: '100%',
centered: true,
fullscreen: true,
modal: true,
hideOnMaskTap: true,
showAnimation: {
type: 'popIn',
duration: 250,
easing: 'ease-out'
},
hideAnimation: {
type: 'popOut',
duration: 250,
easing: 'ease-out'
},
}).show();
}
}
}
}
});
If you want to see the webapp, here's the link: http://www.ciamcostruzioni.it/CIAM_app/not_compiled/
Thanks in advance.
I have made some changes in your code. Check it:
http://jsfiddle.net/JCarlesVilaseca/NZj3N/
Ext.define('CIAM_app.view.Cataloghi', {
extend: 'Ext.NestedList',
xtype: 'cataloghi',
requires: ['Ext.data.TreeStore', 'Ext.carousel.Carousel'],
fullscreen: true,
config: {
iconCls: 'books',
iconMask: true,
title: 'Cataloghi',
styleHtmlContent: true,
store: Ext.create('CIAM_app.store.lista_cataloghiStore'),
variableHeights: true,
listConfig: {
itemTpl: '<tpl if="leaf == false"><img src="http://www.ciamcostruzioni.it/CIAM_app/not_compiled/{icon}" alt="{text}" class="cataloghi_img" /></tpl><tpl if="leaf == true"><p class="cataloghi_p">{text}</p></tpl>'
},
listeners: {
leafitemtap: function(nestedList, list, index, target, record) {
var detailCard = nestedList.getDetailCard();
var pagina = record.get('immagini_catalogo');
var n = record.get('pagine_catalogo');
items = [];
if (detailCard.getData() !== null) {
detailCard.getStore().removeAll(true, true);
}
for (i = 1; i <= n; i++) {
items.push({
src: 'http://www.ciamcostruzioni.it/CIAM_app/not_compiled/gallery/' + pagina + '/' + i + '.jpg'
});
}
detailCard.setData(items);
detailCard.refresh();
}
},
detailCard: {
xtype: 'dataview',
itemTpl: '<img src="{src}">',
cls: 'immagine_catalogo',
listeners: {
itemtap: function(dataView, index, target, record, e, eOpts) {
Ext.Viewport.add({
xtype: 'catalogues_carousel',
listeners: {
initialize: function() {
this.setItems(dataView.getData());
this.setActiveItem(index);
}
}
}).show()
}
}
}
}
});
Ext.define('CIAM_app.view.Cataloghi_carousel', {
extend: 'Ext.Carousel',
xtype: 'catalogues_carousel',
requires: ['Ext.carousel.Carousel'],
config: {
fullscreen: true,
defaultType: 'image',
style: {
'background': 'rgba(206,203,203,0.87)',
'z-index':10
},
indicator: false,
modal: true,
showAnimation: {
type: 'popIn',
duration: 250,
easing: 'ease-out'
},
hideAnimation: {
type: 'popOut',
duration: 250,
easing: 'ease-out'
}
},
initialize: function() {
this.element.on('tap',function() {
this.hide();
});
}
});

How to get dynamically images from the store to the carousel sencha touch 2

Im trying to get images from a store , and control the number of the images , and show 12 images for each carousel ,all of that dynamically depending of the number of images on the store , if its up to ex: 12 ,to create an other carousel for the rest ...
but i've tried to begin with getting just images from the store and load it to the carousel , but my view is empty , nothing is diplaying ..
The model :
Ext.define("MyApp2.model.ApplicationModel", {
extend: "Ext.data.Model",
config: {
//type:'tree',
fields: [
{name: 'id', type: 'auto'},
{name: 'name', type: 'auto'},
{name:'icon',type:'image/jpg'}
]
}
});
The store :
var token=localStorage.getItem("access_token");
Ext.define("MyApp2.store.ApplicationStore", {
extend: "Ext.data.Store",
requires: ["Ext.data.proxy.JsonP"],
config: {
model: "MyApp2.model.ApplicationModel",
autoLoad: true,
id :'ApplicationStr',
proxy: {
type: 'jsonp',
url: 'http://mysite.com/api/applications?format=jsonp&access_token='+token,
reader: {
type: 'json',
rootProperty: 'applications'
}
}
}
});
var store = Ext.create('MyApp2.store.ApplicationStore');
store.getStore('ApplicationStr');
myCarousel = Ext.getCmp('carouselid');
store.each(function(record) {
myCarousel.add({
html: '<img src=' + record.get('icon') + '/>'
});
});
The view :
Ext.define('MyApp2.view.MainMenu', {
extend: 'Ext.Panel',
requires: ['Ext.TitleBar', 'MyApp2.store.ApplicationStore', 'Ext.dataview.List', 'Ext.Img'],
alias: 'widget.mainmenuview',
config: {
layout: {
type: 'fit'
},
items: [{
xtype: 'titlebar',
title: 'My Apps',
docked: 'top',
items: [
{
xtype: 'button',
text: 'Log Off',
itemId: 'logOffButton',
align: 'right'
}
]
},
{
xtype: "carousel",
id: 'carouselid'
}
],
listeners: [{
delegate: '#logOffButton',
event: 'tap',
fn: 'onLogOffButtonTap'
}]
},
onLogOffButtonTap: function() {
this.fireEvent('onSignOffCommand');
}
});
May be data in store is not loaded before you started iterating over it. To avoid such cases you should always use data in load events callback.
You can do 2 things, either add load listener in store and do carousel population in it
listeners:{
load: function( me, records, successful, operation, eOpts ){
console.log("data loaded", records);
myCarousel = Ext.getCmp('carouselid');
for(var i=0; i<records.length; i++){
myCarousel.add({
html: '<img src=' + records[i].get('icon') + '/>'
});
}
}
}
or you can call load manually when required and do it in callback like this:
store.load({
callback: function(records, operation, success) {
myCarousel = Ext.getCmp('carouselid');
for(var i=0; i<records.length; i++){
myCarousel.add({
html: '<img src=' + records[i].get('icon') + '/>'
});
}
},
scope: this
});

Passing rowIndex to a window in extjs 4

I have a store, a grid, a window and a few text boxes in the window. What I need is that on clicking the actioncolumn in the grid, i need to get the rowIndex of the clicked row and pass it to the window as a parameter. There, i need to load the store and get the values and set it in the appropriate textboxes. I'm not sure how to pass the rowIndex from grid to window on click. Wen I try to alert the value of a in the testfunction, it comes up as undefined. Pls help and below is my code.
Js File:
Ext.onReady(function() {
var rIx;
Ext.create('Ext.data.Store', {
storeId:'employeeStore',
fields:['firstname', 'lastname', 'senority', 'dep', 'hired'],
data:[
{firstname:"Michael", lastname:"Scott", senority:7, dep:"Manangement", hired:"01/10/2004"},
{firstname:"Dwight", lastname:"Schrute", senority:2, dep:"Sales", hired:"04/01/2004"},
{firstname:"Jim", lastname:"Halpert", senority:3, dep:"Sales", hired:"02/22/2006"},
{firstname:"Kevin", lastname:"Malone", senority:4, dep:"Accounting", hired:"06/10/2007"},
{firstname:"Angela", lastname:"Martin", senority:5, dep:"Accounting", hired:"10/21/2008"}
]
});
Ext.create('Ext.grid.Panel', {
title: 'Employee Data',
store: Ext.data.StoreManager.lookup('employeeStore'),
columns: [
{ text: 'First Name', dataIndex: 'firstname' },
{
header: 'Button',
xtype: 'actioncolumn',
icon : 'test.png',
handler: function(grid, rowIndex, colIndex, item, e , record) {
rIx=rowIndex;
//var rec = grid.getStore().getAt(rowIndex);
//alert("Edit " + rec.get('firstname'));
Ext.create('MyWindow').show();
}
}
],
width: 500,
renderTo: Ext.getBody()
});
var testFunction = function(a){alert("a= "+a);
var r = Ext.data.StoreManager.lookup('employeeStore').getAt(a);
var firstname = r.get('firstname');
Ext.getCmp('fname').setValue(firstname);
};
Ext.define('MyWindow', {
extend: 'Ext.window.Window',
store : Ext.data.StoreManager.lookup('employeeStore'),
height: 250,
width: 250,
title: 'My Window',
items: [
{
xtype: 'textfield',
id : 'fname',
fieldLabel:'Name'
}
],
listeners: {
afterrender: Ext.Function.pass(testFunction, [rIx])
}
});
});
Ext.Function.pass(testFunction, [rIx]) takes the current value of rIx when pass is executed. The method is being called long before rIx is ever set to anything meaningful. Javascript is a pass-by-value language. It doesn't matter that eventually rIx gets set to the row index. By that point Ext.Function.pass has already been executed and the parameter it passed in was undefined.
Another approach is to just push the rowIndex onto your window as a property.
Ext.create('Ext.grid.Panel', {
title: 'Employee Data',
store: Ext.data.StoreManager.lookup('employeeStore'),
columns: [
{ text: 'First Name', dataIndex: 'firstname' },
{
header: 'Button',
xtype: 'actioncolumn',
icon : 'test.png',
handler: function(grid, rowIndex, colIndex, item, e , record) {
Ext.create('MyWindow', {rIx: rowIndex}).show();
}
}
],
width: 500,
renderTo: Ext.getBody()
});
Ext.define('MyWindow', {
extend: 'Ext.window.Window',
store : Ext.data.StoreManager.lookup('employeeStore'),
height: 250,
width: 250,
title: 'My Window',
items: [
{
xtype: 'textfield',
id : 'fname',
fieldLabel:'Name'
}
],
listeners: {
afterrender: function(win){
alert("idx= " + win.rIx);
var r = Ext.data.StoreManager.lookup('employeeStore').getAt(win.rIx);
var firstname = r.get('firstname');
Ext.getCmp('fname').setValue(firstname);
}
}
});
Another option is to setup the window's afterrender listener in your handler function instead of adding it in the window's class definition. This approach is a bit cleaner in my opinion. I'm not a big fan of adding unrelated state properties to components.
Ext.create('Ext.grid.Panel', {
title: 'Employee Data',
store: Ext.data.StoreManager.lookup('employeeStore'),
columns: [
{ text: 'First Name', dataIndex: 'firstname' },
{
header: 'Button',
xtype: 'actioncolumn',
icon : 'test.png',
handler: function(grid, rowIndex, colIndex, item, e , record) {
var win = Ext.create('MyWindow');
// add the listener after to avoid bashing any listener config
// that may already exist for the window.
win.on('afterrender', function() {
// rowIndex is available in the closure
alert("idx= " + rowIndex);
var r = Ext.data.StoreManager.lookup('employeeStore').getAt(rowIndex);
var firstname = r.get('firstname');
Ext.getCmp('fname').setValue(firstname);
});
win.show();
}
}
],
width: 500,
renderTo: Ext.getBody()
});

Sencha Touch 2 Navigation View responding very slowly

I am a newbie to Sencha Touch 2 . I am building an PhoneGap + Sencha Touch 2 application for Android 2.3.4 . I completed developing my application . While testing the app , i found out that the navigation view i used is responding very slow on tap of disclosure item.
I am using a list container view , list view and editor view . The code for them is given below .
The below piece of code works fine but on the tap of disclosure item the incident editor view is shown after 10 secs and i sometimes even don't know whether it was clicked or not .
So i need help in two things :
1.) When i click on disclosure item i should show masking to know that i clicked it atleast
2.) Or speed up the show of incident editor view
ListContainer View :
Ext.define('Sample.view.ListContainer', {
extend: 'Ext.NavigationView',
xtype:'listContainer',
id: 'idListContainer',
config: {
id:'idIncidentListContainer',
items:[
{
xtype:"incidentsList",
cls: "clsHeader"
}
]
}
});
List View:
Ext.define("Sample.view.IncidentsList", {
extend: "Ext.Panel",
xtype: 'incidentsList',
id: 'idIncidentList',
requires:[
'Ext.dataview.List',
'Ext.data.proxy.Memory',
'Ext.data.Store',
],
alias:'widget.incidentslist',
config: {
id: 'idIncidentList',
layout:'fit',
items: [
{
xtype: "toolbar",
docked: "top",
ui:'light',
id:"idHeaderTwo",
cls:"clsHeaderTwo" ,
items: [
{ xtype: 'title' ,
cls: 'clsLeftTitle',
title: "My Incidents",
},
{ xtype: 'spacer'},
{ xtype: 'title' ,
cls: 'clsRightTitle',
id: 'idIncidentsListTitle',
title:"Welcome",
},
]
},
{
xtype: "list",
store: "IncidentStore",
itemId:"incidentsList",
id:"inclist",
loadingText: "Loading Incidents...",
emptyText: "<div class=\"empty-text\">No incidents found.</div>",
onItemDisclosure: true,
itemTpl: Ext.create('Ext.XTemplate',
'<tpl if="TKT_STATUS_NAME == \'CLOSED\'">',
'<div class="vm_statusRed">',
'</tpl>',
'<tpl if="TKT_STATUS_NAME == \'OPENED\'">',
'<div class="vm_statusYellow">',
'</tpl>',
'<tpl if="TKT_STATUS_NAME == \'ASSIGNED\'">',
'<div class="vm_statusOrange">',
'</tpl>',
'<tpl if="TKT_STATUS_NAME == \'PENDING\'">',
'<div class="vm_statusRed">',
'</tpl>',
'<tpl if="TKT_STATUS_NAME == \'RESOLVED\'">',
'<div class="vm_statusOrange">',
'</tpl>',
'<tpl if="TKT_STATUS_NAME == \'REOPEN\'">',
'<div class="vm_statusYellow">',
'</tpl>',
'<div class="vm_dvList"><h4 class="vm_txtName"><span class="vm_listHeader"><label>Inci.#{TKT_ID} by </label><label class="vm_txtFirstName"><i>{FIRST_NAME:ellipsis(15, true)}</i></label></span><div class="date vm_clsDate">{CREATED_ON:date("d-M-y H:i")}</div></h4>',
'<div class="vm_title">{TKT_SUBJECT}</div>',
'<div class="vm_subDesc">{TKT_DESC}</div></div></div>'
)
}],
listeners: [
{
delegate: "#incidentsList",
event: "disclose",
fn: "onIncidentsListDisclose",
loadingText: "Loading ...",
},
]
},
initialize: function() {
this.callParent(arguments);
var getLoginData = localStorage.getItem('userData');
var parseData = JSON.parse(getLoginData);
var fname = parseData[0].FIRST_NAME;
var getIncidentData = localStorage.getItem('userIncidentData');
var parseIncidentData = JSON.parse(getIncidentData);
Ext.getCmp("idIncidentsListTitle").setTitle("Welcome, " + fname);
Ext.getStore("IncidentStore").setData(localStorage.userIncidentData).load();
},
onIncidentsListDisclose: function (list, record, target, index, evt, options) {
console.log("editIncidentCommand");
/*var list = Ext.getCmp('idIncidentList');
list.setMasked({
xtype:'loadmask',
message:'Loading...'
});*/
this.fireEvent('editIncidentCommand', this, record);
}
});
Editor View :
Ext.define("Sample.view.IncidentEditor", {
extend: 'Ext.form.Panel',
xtype: 'incidentsEditor',
id:'incidentsEditorView',
alias: "widget.incidenteditorview",
config: {
scrollable: 'vertical',
id:'idIncidentEditor',
layout:'vbox',
items: [
{
xtype: "toolbar",
docked: "top",
ui:'light',
id:"idHeaderTwo",
cls:"clsHeaderTwo",
items: [
{ xtype: 'title' ,
cls: 'clsLeftTitle',
title: "Incident Details",
},
{xtype: 'spacer'},
{ xtype: 'title' ,
cls: 'clsRightTitle',
id: 'idIncidentEditorTitle',
title:"Welcome",
},
]
},
{ xtype: "fieldset",
items: [
{
xtype: 'textfield',
name: 'TKT_SUBJECT',
label: 'Subject',
labelAlign: 'top',
cls:'vm_fieldFont',
clearIcon:false,
disabled:true
},
{
xtype: 'textareafield',
name: 'TKT_DESC',
label: 'Description',
labelAlign: 'top',
cls:'vm_fieldFont',
clearIcon:false,
disabled:true
},
{
xtype: 'textfield',
name: 'SEV_DESC',
label: 'Impact',
labelWidth:'45%',
cls:'vm_fieldFont',
clearIcon:false,
disabled:true
},
{
xtype: 'textfield',
name: 'SERVICE_NAME',
id:'displayIncident',
cls:'vm_fieldFont',
label: 'IncidentType',
disabled: true,
labelWidth:'45%',
},
{
xtype: 'textfield',
label: 'Category',
name: 'CATEGORY_NAME',
cls:'vm_fieldFont',
id:'getCategory',
labelWidth:'45%',
disabled: true,
},
]
},
],
},
initialize: function() {
var getLoginData = localStorage.getItem('userData');
var parseData = JSON.parse(getLoginData);
var fname = parseData[0].FIRST_NAME;
Ext.getCmp("idIncidentEditorTitle").setTitle("Welcome, " + fname);
//var list = Ext.getCmp('idIncidentList');
//list.unmask();
},
onIncidentsListDisclose: function (list, record, target, index, evt, options) {
console.log("editIncidentCommand");
this.fireEvent('editIncidentCommand', this, record);
}
});
Controller:
Ext.define("Sample.controller.Incidents", {
extend: "Ext.app.Controller",
config: {
refs: {
//lookup for views by xtype
incidentsListView:'incidentslist',
incidentEditorView: 'incidenteditorview',
incidentsList: 'incidentsList',
listContainer:'listContainer'
},
control: {
incidentsListView: {
//commands fired by the Incidents list container.
editIncidentCommand: "onEditIncidentCommand",
},
}
},
//Transitions
slideLeftTransition: { type: 'slide', direction: 'left' },
slideRightTransition: { type: 'slide', direction: 'right' },
//Helper function(generates random integer)
getRandomInt: function (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
},
//Function to get incident details and set them to incidentview
activateIncidentEditor: function (record) {
var incidentContainer = this.getListContainer();
var incidentEditorView = Ext.create("Sample.view.IncidentEditor");
incidentEditorView.setRecord(record); // load() is deprecated.
incidentContainer.push(incidentEditorView);
},
//on edit incident command
onEditIncidentCommand: function (list, record) {
this.activateIncidentEditor(record);
}
});
Please help me guys ... Thanks in Advance ...!!!
I experience the same problems. Coding Sencha Touch 2 in MVC format makes the app's respond super-slow on "old" hardware. Especially Android. It's the drawback of HTML5 vs Native. However they claim the performance would increase when manually building the lib, I experienced almost no improvement.
On Android most performance based issues are related to Animations though. Try setting the show/hide animations to none and see if it improves.
You can also try setting the onBackButtonTap and other events on the controller though. That should improve the page rendering allot.
I had a similar problem, in my case the solution was this:
http://www.sencha.com/forum/showthread.php?184341-Best-practice-to-prevent-App-peformance-from-Slowly-degrading-after-drilling-around&p=900511&posted=1#post900511

Panel not hiding properly

I have a panel whose items are a list and a panel like below
When I click on a button, I want to hide this panel. So far, I managed to do that, but this is what I get
I would like to know how to remove this grey space form the bottom of the panel.
I already this but it's not working :
this.toolsPnl.hide({type:'slide', direction:'up'});
this.doComponentLayout();
this.doLayout();
Update : Code
this.pasteBtn = new Ext.Button({
cls:'paste-copy-tools-panel',
text: 'Coller',
ui: 'normal',
handler : this.onPasteBtnTap,
scope:this
});
this.cancelBtn = new Ext.Button({
cls:'cancel-copy-tools-panel',
text: 'Annuler',
ui: 'normal',
handler: this.onCancelBtnTap,
scope:this
});
this.toolsPnl = new Ext.Panel({
layout:{type:'hbox', align:'stretch'},
height:40,
cls:'document-tools-panel',
hidden:true,
items:[this.pasteBtn,this.cancelBtn]
});
this.currentFolderPnl = new Ext.Panel({
cls:'document-current-folder-panel',
html:'/'
});
this.list = new Ext.List({
flex:1,
cls:'document-list',
id: 'document-list',
store: app.stores.Document,
itemTpl: app.templates.document
});
app.views.DocumentList.superclass.constructor.call(this, {
selectedCls : "x-item-selected",
dockedItems: [{
xtype: 'toolbar',
ui:'dark',
title: 'Documents',
items:[this.backBtn,{xtype:'spacer'},this.newBtn]
}],
layout: 'vbox',
items: [
this.currentFolderPnl,
this.list,
this.toolsPnl,
]
});
May help you with some hack. The main trick is in fixListHeight function, but for showing tools panel for the first time I have to call doComponentLayout for its container first. Don't know why this functionality doesn't work out of the box... have the feeling there is something I have missed. Nevertheless, here is the code.
new Ext.Application({
launch: function() {
// helper property
// indicates whether toolsPnl was shown already
this.first = true;
this.viewport = new Ext.TabPanel({
fullscreen: true,
layout: 'card',
dockedItems: [{
xtype: 'toolbar',
dock: 'top',
items: [{
xtype: 'spacer'
}, {
text: 'show',
listeners: {
tap: function (btn) {
var panel = Ext.getCmp('toolsPnl');
if (panel.isHidden()) {
panel.show({type:'slide', direction:'up'});
btn.setText('hide');
} else {
panel.hide({type:'slide', direction:'up'});
btn.setText('show');
this.fixListHeight();
}
},
scope: this
}
}]
}],
tabBar: {
layout: {
type: 'fit'
}
},
tabBarDock: 'bottom',
items: [{
title: 'Some tabs here...',
id: 'docTab',
iconCls: 'favorites',
layout: 'card',
dockedItems: [{
id: 'toolsPnl',
dock: 'bottom',
html: 'Tools panel',
style: {
'background-color': 'lightblue',
'line-height': '2em',
'text-align': 'center',
'height': '40px',
'width': '100%'
},
hidden:true,
listeners: {
show: function () {
if (this.first) {
Ext.getCmp('docTab').doComponentLayout();
this.fixListHeight();
this.first = false;
}
Ext.defer(function () {
this.fixListHeight(-1);
}, 250, this);
},
scope: this
}
}],
items : [{
xtype: 'list',
id: 'docList',
itemTpl: '{item}',
store: new Ext.data.Store({
data: [{item: 'Some data in the list...'}],
fields: ['item']
})
}]
}]
});
this.fixListHeight = function (direction) {
var panel = Ext.getCmp('toolsPnl'),
tab = Ext.getCmp('docTab'),
list = Ext.getCmp('docList'),
el,
h = list.getHeight(),
dh = panel.getHeight(),
dir = direction || 1;
el = tab.getEl().child('.x-panel-body');
el.setHeight(h + dh * dir);
el.child('.x-list').setHeight(h + dh * dir);
el.down('.x-scroller').setHeight(h + dh * dir);
};
}
});
That looks like the default sencha touch grey. A simple work around would be adding the code below to the panel
style:'background-color:White'