Sencha Touch dynamically add buttons with line wrap - button

in an actionsheet with a titlebar and a list, I'm implementing some buttons to be used for filtering the store ("ListinoStore") the list is bound to.
The buttons are generated dynamically for each item in a store; items could be 4+, so buttons are expected to span over one o more lines.
The buttons are added to a panel, which is set between the Titlebar and the List.
I'm only getting all buttons in a single line, those beyond the viewport are hidden: how could I get them automatically wrapping over two or more lines?
I unsuccessfully tried using layout: 'hbox', or other things.
// the store
{
"success":true
, "total": 9
, "root": [
{"tag" : "white"}
, {"tag" : "red"}
, {"tag" : "blue"}
, {"tag" : "green"}
, {"tag" : "orange"}
, {"tag" : "purple"}
, {"tag" : "yellow"}
, {"tag" : "pink"}
, {"tag" : "grey"}
]
}
var TagsPanel = new Ext.Panel({
items: [
{
xtype : 'button'
, text: 'All'
, ui: 'small'
, handler: function() {
ListinoStore.clearFilter();
}
}
]
});
TagsStore.each(function(record){
TagBtn = new Ext.Button({
text: record.get('tag')
, style: 'float: left;'
, ui: 'small'
, handler: function() {
ListinoStore.clearFilter();
ListinoStore.filter(function(item) {
return item.get('tag').search(record.get('tag')) > -1;
});
}
});
TagsPanel.add(TagBtn);
});
var ListinoSheet = new Ext.ActionSheet({
fullscreen: true
, layout: 'vbox'
, style: 'top:0px'
, defaults: {
handler: function(btn, evt) {
this.parent.hide();
} // handler
} // defaults
, items: [
{
xtype: 'titlebar'
, title: 'Le nostre migliori pizze'
, ui: 'light'
}
, TagsPanel
, {
xtype: 'ListinoList'
, flex: 1
}
]
});
UPDATE
If I config the TagsPanel with docked: 'top', removing any layout config both from the panel and the buttons, I get the buttons lining in the right way, but of course on the top of the titlebar.

I solved
I configured both the titlebar and the tagspanel with docked: 'top'.

Related

ExtJs submit menubutton values

I am trying to submit the values from the menu buttons but know this is not possible and that I have to create a hidden field and store the button values there.
Being new to ExtJs I can not seem to figure out how to do this. Below is the basic layout I used to check the button shows and I can choose a colour.
getFormItems : function() {
var me = this;
return [{
xtype : "fieldset",
title : "Items to monitor",
defaults : {
labelSeparator : ""
},
items : [{
xtype : "checkbox",
name : "cpuenable",
boxLabel : _("Will monitor CPU Temperature"),
fieldLabel : _("CPU Temperature"),
checked : false
},{
xtype : 'hiddenfield',
id : 'buttonvalues'
},{
xtype : "button",
name : "colours",
text : _("Choose Colours"),
scope : this,
style : {
marginTop : "10px",
marginBottom : "10px"
},
menu: [{
text: "Main CPU Colour",
menu: {
xtype : "colormenu",
name : "colourc",
value : "000000",
cls : "menubutton-class",
handler: function (obj, rgb) {
var colourmField = this.findField('colourc');
colourmField.setValue(rgb.toString());
alert(colourmField.getValue());
}
}
},{ and so on
Okay, here is an edit for you of my previous post. I give you an example how to fetch all child components you want inside a component:
Example extjs:
{
xtype: 'fieldset',
id: 'fsButtons',
items: [
{
xtype: 'hiddenfield',
id: 'hiddenValues'
},
{
xtype: 'button'
color: '000000'
},
{
xtype: 'button'
color: '555555'
}
]
}
Function to fill the hiddenfield:
function getButtonVars() {
var buttonVars = new Array();
//Get all components with xtype 'button' inside the fieldset with id 'fsButtons'
Ext.Array.each(Ext.ComponentQuery.query('button', Ext.getCmp('fsButtons'), function(button){
buttonVars.push(button.color);
});
Ext.getCmp('hiddenValues').setValue(buttonVars.join(',')); // concats all button values to one string: '000000,555555' etc.
}
I hope it's clear now :)
http://docs-origin.sencha.com/extjs/4.2.2/#!/api/Ext.ComponentQuery

Sencha touch grid templatecolumn listener no working

Hi i need i have button in my sencha touch grid. I need to fire the button event. Please c the code below
xtype: 'grid',
store : { xclass : 'JPM.store.MuatTurun.MuatTurun'},
title :'Muat Turun',
width: '100%',
itemHeight: 70,
columns: [
{
header: 'Name' ,
itemId: 'mycolumn1',
flex: 1 ,
xtype: 'templatecolumn' ,
tpl: '<button><div class="muatTurun">Muat Turun</div></button>',
listeners: {
click: function(){
console.log('click');
},
dblclick: function(){
console.log('dblclick');
} ,
itemclick: function(dv, record, item, index, e) {
alert('working');
},
}
}
] ,
plugins: [
{
type: 'gridpagingtoolbar'
}
]
}
]
}
But the listener inside template column is not working. Any solutions?

ExtJS 3.4 add button at the bottom of a grid

I'm new to ExtJS and try to add a button at the bottom of the grid. This button will open a modal dialog to select more persons. I don't know how to add this button after the grid. Do I have to use another component than GridPanel?
Can somebody help me?
The code looks like:
var selectedPersons = [
[1, 'Persnr', 'Name', 'Vorname']
];
var store = new Ext.data.ArrayStore({
fields: [
{name: 'PrsOid', type: 'int'},
{name: 'PersonalNr'},
{name: 'Nachname'},
{name: 'Vorname'}
]
});
store.loadData(selectedPersons);
var grid = new Ext.grid.GridPanel({
store: store,
columns:
[
{
id : 'PersonalNr',
header : 'PersonalNr',
width : 100,
sortable : true,
dataIndex: 'PersonalNr'
},
{
header : 'Nachname',
width : 100,
sortable : true,
dataIndex: 'Nachname'
},
{
header : 'Vorname',
width : 100,
sortable : true,
dataIndex: 'Vorname'
}
],
stripeRows: true,
autoExpandColumn: 'PersonalNr',
height: 200,
//width: 460,
title: 'Personenauswahl',
// config options for stateful behavior
stateful: true,
stateId: 'grid'
});
grid.render('gridSelectedPersons');
Do you mean something like a bottom bar ?
var grid = new Ext.grid.GridPanel({
store: store,
columns:
[
....
],
stripeRows: true,
autoExpandColumn: 'PersonalNr',
bbar: new Ext.Toolbar({
renderTo: document.body,
height: 30,
items: [
// begin using the right-justified button container
'->',
{
xtype:'button',
text:'The button',
//makes the button 24px high, there is also 'large' for this config
scale: 'medium'
}
]
})

ExtJS4 - How to add file upload editor in Grid?

I want to create Grid that has 3 columns. One column is 'textfield' and the other two columns are image which I set editor as 'filefield'. On image column I can display image by using renderer but when it comes to edit or add new image I can't press the browse button to browse image. Here is my code.
var grid = Ext.create('Ext.grid.Panel', {
title: 'Author',
store: Ext.data.StoreManager.lookup('authorStore'),
renderTo: 'authorGrid',
columns: [{
header: 'Name',
dataIndex: 'name',
editor: {
xtype: 'textfield',
}
}, {
header: 'Icon',
dataIndex: 'iconImage',
renderer: function(val) {
return '<img src="' + val + '">';
},
editor: {
xtype: 'filefield',
allowBlank: false,
}
}, {
header: 'Background',
dataIndex: 'background',
renderer: function(val) {
return '<img src="' + val + '">';
},
editor: {
xtype: 'filefield',
allowBlank: false,
}
}],
selModel: Ext.create('Ext.selection.CheckboxModel'),
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 2
})
],
tbar: [{
iconCls: 'icon-add',
text: 'Add',
handler: function() {
// add record
}
}, {
iconCls: 'icon-delete',
text: 'Remove',
handler: function() {
// remove selected records...
}
}, {
iconCls: 'icon-save',
text: 'Save',
handler: function() {
store.save();
}
}]
});
What does it wrong? Can I put 'filefield' editor like this? Is it possible to click save button on grid for save grid data and upload images?
After quick investigation I didn't realized any easy solutions for this issue. In my view EditorGrid isn't supposed to support such type of operations.
And moreover - editor in grid is intended to modify value in corresponding row of the store. With fileupload you operate with files, but as I see in you code you are waiting for a string data in these cells.
What I suggest is replace the fileupload in cells with a popup. When user clicks a cell, you will open popup with fileupload. When they select a file and upload it - you close the popup and reload record in grid's store. Just an idea!

Change Button-Text (selectfield) - Sencha Touch

how can i change the button-text ("Done" and "Cancel") in the selectfield to german or in any text i like?
xtype: 'selectfield',
name: 'sector',
width: 150,
prependText: 'Sector:',
options: [
{text: 'Alle Termine', value: 'alldates'},
]
one easy possibilty would be to override the defaults of the picker, e.g.:
Ext.override(Ext.Picker, {
doneButton: 'Fertig',
cancelButton: 'Abbrechen'
});
You can extend Ext.form.Select to allow you to apply your own configuration to the picker it uses.
Ext.ns('MySite.ux.form');
MySite.ux.form.Select = Ext.extend(Ext.form.Select , {
getPicker: function() {
if (!this.picker) {
this.picker = new Ext.Picker(Ext.apply({
slots: [{
align : 'center',
name : this.name,
valueField : this.valueField,
displayField: this.displayField,
value : this.getValue(),
store : this.store
}],
listeners: {
change: this.onPickerChange,
scope: this
}
}, this.pickerConfig));
}
return this.picker;
}
});
Ext.reg('myselectfield', MySite.ux.form.Select);
And your selectfield configuration might look like this:
{
xtype: 'myselectfield',
name: 'sector',
label: 'Sector',
pickerConfig: {
doneButton: 'Fertig',
cancelButton: 'Abbrechen'
}
}

Resources