Sencha Touch Grid columns cannot resize to fullscreen - sencha-touch-2

I am new to sencha, I am trying to use Sencha Touch Grid extension in sencha Architect 3 to display lists of elements which includes texts and images. I have been able to display these data inside a touch grid component but I can't get these columns to resize to fullscreen size. I have spent hours trying to get it work without making any head way. Below is the code snippet for the view. Any advice and help will be appreciated.
Ext.define('MyApp.view.MyGridView', {
extend: 'Ext.grid.Grid',
alias: 'widget.myGridView',
requires: [
'Ext.grid.column.Template',
'Ext.XTemplate',
'Ext.grid.plugin.MultiSelection',
'Ext.grid.plugin.ViewOptions',
],
config: {
centered: false,
fullscreen: false,
height: '100%',
styleHtmlContent: true,
width: '100%',
emptyText: 'No records found',
store: 'Usines',
itemHeight: 50,
variableHeights: true,
title: 'Sites',
columns: [
{
xtype: 'templatecolumn',
styleHtmlContent: true,
tpl: [
' <div>',
' <img class="photo" src="data:image/png;base64,{picture}" />',
' </div>'
],
width: 65,
dataIndex: 'picture',
text: 'Photo'
},
{
xtype: 'templatecolumn',
styleHtmlContent: true,
tpl: [
'<div float:left>',
' <strong>{name}</strong>',
'</div> '
],
width: 150,
dataIndex: 'name',
text: 'Name'
},
{
xtype: 'templatecolumn',
styleHtmlContent: true,
tpl: [
'<div>',
' <tpl if="statutKpi==0">',
' <img src ="images/status_green.png"/> ',
' </tpl>',
' <tpl if="statutKpi==1">',
' <img src ="images/status_orange.png"/> ',
' </tpl>',
' ',
' <tpl if="statutKpi==2">',
' <img src ="images/status_red.png"/>',
' </tpl>',
'</div>'
],
width: 70,
align: 'center',
dataIndex: 'statusKpi',
text: 'Kpi'
},
{
xtype: 'templatecolumn',
minWidth: 10,
styleHtmlContent: true,
tpl: [
'<div float:right>',
'',
' <tpl if="statutEvent==0">',
' <img src ="images/msg_green.png"/> ',
' </tpl>',
' <tpl if="statutKpi==1">',
' <img src ="images/msg_red.png"/> ',
' </tpl>',
'',
'</div>'
],
width: 80,
align: 'center',
text: 'Event'
}
],
plugins: [
{
type: 'gridmultiselection'
},
{
type: 'gridviewoptions'
}
]
},
initialize: function() {
Ext.Viewport.add({
xclass:'MyApp.view.MyGridView'
});

Related

Sencha Touch 2 overlay showBy html div

How can I use this to show by a div:
Html
<div class='clickable'>Tap me</div>
JS code (tap is connected to the div element above)
tap : function(e) {
overlay = Ext.Viewport.add({
xtype: 'panel',
left: 0,
top: 0,
modal: true,
hideOnMaskTap: true,
hidden: true,
width: 260,
height:'70%',
html: 'STUFF!!',
styleHtmlContent: true,
scrollable: true,
items: [
{
docked: 'top',
xtype: 'toolbar',
title: 'Overlay Title'
}
]
});
overlay.showBy(e.getTarget());
}
However this is a nightmare, I'll get these errors with e.getTarget() or e.target, it does work with .show() but its positioning is then wrong. What is the correct way to do this?
Uncaught TypeError: Object #<HTMLTableCellElement> has no method 'getPageBox'
You probably want to use event delegation on your HTML div tag. So you can give your div tag an id:
<div class='clickable' id='myId'>Tap me</div>
listeners : {
tap: {
fn: function() {},
element: 'element',
delegate: '#myId'
}
}
You can hack it by overlaying an invisible Ext.Button over your html div! You'll just have to add a painted function to render the new button...
tpl: '<div class='clickable'>Tap me</div>'
.......
listeners: {
painted : function(){
var clickable = Ext.DomQuery.select('.pageClass .clickable')[0];
var invisibleButton = new Ext.Button({
text: 'whatever',
renderTo: clickable,
cls: 'something',
width: '100%',
// set styles as transparent bg, no border etc...
handler: function(){
var overlay = Ext.Viewport.add({
xtype: 'panel',
left: 0,
top: 0,
modal: true,
hideOnMaskTap: true,
hidden: true,
width: 260,
height:'70%',
html: 'STUFF!!',
styleHtmlContent: true,
scrollable: true,
items: [
{
docked: 'top',
xtype: 'toolbar',
title: 'Overlay Title'
}
]
});
overlay.showBy(this);
}
});
}
}
Tested and working.
You need to do it like this:
tap : function(e) {
var overlay = Ext.create('Ext.Panel', {
xtype: 'panel',
left: 0,
top: 0,
modal: true,
hideOnMaskTap: true,
hidden: true,
width: 260,
height:'70%',
html: 'STUFF!!',
styleHtmlContent: true,
scrollable: true,
items: [
{
docked: 'top',
xtype: 'toolbar',
title: 'Overlay Title'
}
]
});
overlay.showBy(e.getTarget());
}
That is to say, do not add to viewport ... create the panel instead.

disable update while collapse and expand treegrid extjs 4

I have treegrid extjs 4.. I use proxy read, create, update and delete
but the problem is the treegrid always send update when I click collapse and expand in treegrid..
when I delete update proxy, I got collapsing failed..
anybody have idea to disable updating while collapsing and expanding??
this is my short code
Ext.define('storeLapObjTP', {
extend: 'Ext.data.TreeStore',
//storePlanningTP = Ext.create('Ext.data.TreeStore', {
pageSize:50,
autoSync: true,
model: 'mod_planningTP',
method: 'POST',
proxy: {
type: 'ajax',
api: {
read: base_url+'project/getcomplete',
create: base_url+'project/edit/'+'create',
update: base_url+'project/edit/'+'update',
destroy: base_url+'project/edit/'+'delete'
},
reader: {
type: 'json',
}
},
sorters: [{
property: 'id',
direction: 'desc'
}],
});
Ext.define('gridTPcl', {
extend: 'Ext.tree.Panel',
id:'gridLapTP',
store: storeLapTP = new storeLapObjTP,
collapsible: false,
loadMask: true,
region: 'center',
margins: '0 0 0 0',
autoScroll: false,
useArrows: true,
rootVisible: true,
multiSelect: false,
singleExpand: false,
columns:
[
{
menuDisabled: true,
sortable: false,
xtype: 'actioncolumn',
width: 20,
items: [
{
xtype: 'treecolumn',
header: 'Project Name',
dataIndex: 'name',
width: 300,
align: 'left',
},
{
header: 'Id',
dataIndex: 'id',
hidden:true
},{
text:'Anggaran (Rp.000)',
columns : [
{
header: 'Budget',
dataIndex: 'budget',
width:80,
align: 'center',
}, {
header: 'Total',
dataIndex: 'total',
width:80,
align: 'center',
}
]
}],
selModel: {
selType: 'rowmodel'
},
title: 'Project Tree',
frame: false,
tbar: new Ext.Toolbar({
id: 'tbarlaptp',
items: [
comboYearLapTP,'-',comboYearLapTP,'-',{
id : 'reloadbuttonlaptp',
text: 'Reload',
iconCls: 'reloadButton',
disabled: true,
tooltip: 'Reload Data and Ignore Change',
handler : function(){
this.up().up().store.load();
}
}]
})
,
plugins: [],
});

Sencha Ext JS4.. [Grid ActionColumn] doesn't display

I'm new with sencha js 4. I already followed the instruction from the sencha documentation guide regarding with how to use actioncolumn, but it doesn't display on my grid.
"Where did I miss?. is there anything that I skipped? or is there anything that I didn't included? help.."
I use the kitchenSink sample that sencha provided me. I tried to manipulate it and added an actioncolumn from one of the grids in the kitchenSink sample
Here is my code:
Ext.define('PayrollLite.view.GridExample', {
extend: 'Ext.grid.Panel',
frame: true,
width: 1200,
height: 750,
store: 'Employees',
columns:
[
{ text: 'Employee Code', width: '10%', dataIndex: 'EmployeeCode' },
{ text: 'Last Name', width: '22%', dataIndex: 'LastName'},
{ text: 'First Name', width: '25%', dataIndex: 'FirstName' },
{ text: 'Middle Name', width: '15%', dataIndex: 'MiddleName' },
{ text: 'Position', width: '15%', dataIndex: 'PositionID', sortable: false },
{
xtype:'actioncolumn',
width:50,
items: [{
icon: 'extjs/examples/shared/icons/fam/cog_edit.png', // Use a URL in the icon config
tooltip: 'Edit',
handler: function(grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
alert("Edit " + rec.get('firstname'));
}
},{
icon: 'extjs/examples/restful/images/delete.png',
tooltip: 'Delete',
handler: function(grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
alert("Terminate " + rec.get('firstname'));
}
}]
}
]
});
My best guess would be the widths - try setting the other columns to flex widths instead. Like so:
Ext.define('PayrollLite.view.GridExample', {
extend: 'Ext.grid.Panel',
frame: true,
width: 1200,
height: 750,
store: 'Employees',
columns:
[
{ text: 'Employee Code', flex: '1', dataIndex: 'EmployeeCode' },
{ text: 'Last Name', flex: '2.2', dataIndex: 'LastName'},
{ text: 'First Name', flex: '2.5', dataIndex: 'FirstName' },
{ text: 'Middle Name', flex: '1.5', dataIndex: 'MiddleName' },
{ text: 'Position', flex: '1.5', dataIndex: 'PositionID', sortable: false },
{
xtype:'actioncolumn',
width:50,
items: [{
icon: 'extjs/examples/shared/icons/fam/cog_edit.png', // Use a URL in the icon config
tooltip: 'Edit',
handler: function(grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
alert("Edit " + rec.get('firstname'));
}
},{
icon: 'extjs/examples/restful/images/delete.png',
tooltip: 'Delete',
handler: function(grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
alert("Terminate " + rec.get('firstname'));
}
}]
}
]
});

How can I increase the spacing between items in a VBOX using ExtJS 4.1?

So I'm using ExtJS 4.1. I have a viewport that contains two items. They are stacked correctly but I want to put some space between them. Margins don't seem to work.
var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
Ext.onReady(function() {
Ext.QuickTips.init();
window.formPanel = Ext.widget({
bodyPadding: '5 5 0',
collapsible: false,
defaultType: 'textfield',
frame: true,
id: 'formPanel',
layout: 'form',
renderTo: '',
title: 'Spring Demo 3 (Lookup Transfer Request)',
url: contextPath + '/users/ajax',
width: 450,
xtype: 'form',
buttons: [{
text: 'Check Status',
scope: this,
handler: function() {
formPanel.getForm().submit({
success: function(res, req) {
}
});
}
}],
fieldDefaults: {
msgTarget: 'side',
labelWidth: 105
},
items: [{
afterLabelTextTpl: required,
allowBlank: false,
fieldLabel: 'Username',
name: 'username',
value: ''
}, {
afterLabelTextTpl: required,
allowBlank: false,
fieldLabel: 'TXID',
name: 'txid',
value: ''
}]
});
window.resultsPanel = Ext.widget({
items: [{
id: 'labMessage',
margin: '0 0 0 10',
text: 'Waiting....',
xtype: 'label'
}],
title: 'Results',
xtype: 'panel'
});
window.viewPort = Ext.widget({
items: [formPanel, resultsPanel],
layout: {
align: 'center',
pack: 'center',
type: 'vbox'
},
margins: '10 10 10 10',
padding: '10 10 10 10',
renderTo: 'container',
xtype: 'viewport'
});
});
The Ext.layout.container.VBox layout has the padding and defaultMargins configs that will apply the respective styles to child components. I have no idea why the naming is inconsistent, but that's what the docs say.
Looking at your sample code, it looks like you're applying your margins to the wrong components. If you want spacing between your panels, put the margin/padding settings on the panels themselves instead of on their container.
window.resultsPanel = Ext.widget({
xtype: "panel",
title: "Results",
margin: "10 0 0 0", // Same as CSS ordering (top, right, bottom, left)
items: [{
xtype: "label",
id: "labMessage",
margin: "0 0 0 10",
text: "Waiting..."
}]
});

Change the amount of cards (Sencha Touch Carousel)

We're currently working with the Sencha Touch Carousel, and we got following problem. We haven't seen any easy way to show more than 3 cards / images (default option). The code looks like this
var gallery = new Ext.Carousel({
cls: 'galleryimage',
xtype: 'carousel',
height: '60px',
width: '65px',
items: [{
html: '<img src="static/images/gallery/ex2.jpg" />',
cls: 'image',
},
{
html: '<img src="static/images/gallery/ex2_2.jpg" />',
cls: 'image',
},
{
html: '<img src="static/images/gallery/ex2_3.jpg" />',
cls: 'image',
},
{
html: '<img src="static/images/gallery/ex2_4.jpg" />',
cls: 'image',
},
{
html: '<img src="static/images/gallery/ex2_5.jpg" />',
cls: 'image',
}]
});
It's pretty disturbing that it isn't clearly documentated, since I think alot of people want to do that. I hope there is anyone who has got a really easy way, without having to change other .scss files.
/* EDIT */
Added this code to it:
var gallerypanel = new Ext.Panel({
layout: {
type: 'vbox',
align: 'stretch'
},
defaults: {
flex: 1
},
items: [gallery]
});
Here you go, a working example with 4 cards :
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady: function() {
// Create a Carousel of Items
var carousel1 = new Ext.Carousel({
defaults: {
cls: 'card'
},
items: [
{
title: 'Tab 1',
html: '1'
},
{
title: 'Tab 2',
html: '2'
},
{
title: 'Tab 3',
html: '3'
},
{
title: 'Tab 4',
html: '4'
}]
});
new Ext.Panel({
fullscreen: true,
layout: {
type: 'vbox',
align: 'stretch'
},
defaults: {
flex: 1
},
items: [carousel1]
});
}
});
Hope it helps