JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<link href="http://cdn.sencha.io/touch/sencha-touch-2.1.0/resources/css/sencha-touch.css"
rel="stylesheet" />
<script src="http://cdn.sencha.io/touch/sencha-touch-2.1.0/sencha-touch-all.js"></script>
<!-- <script src="http://cdn.sencha.io/touch/sencha-touch-2.1.0/sencha-touch-all-debug.js"></script> -->
<title>PickerIcons</title>
</head>
<body></body>
</html>
CSS
img.pickerIcon {
height: 25px;
width: 25px;
margin-left: auto;
margin-right: auto;
margin-top: auto;
margin-bottom: auto;
}
JavaScript
Ext.application({
name: 'PickerIcons',
selectOptions: [{
text: 'Diamonds',
value: 'Diamonds',
iconUrl: 'http://s11.postimage.org/pkvgix61b/diamonds.png'
}, {
text: 'Hearts',
value: 'Hearts',
iconUrl: 'http://s11.postimage.org/rqprdf9hr/hearts.png'
}, {
text: 'Spades',
value: 'Spades',
iconUrl: 'http://s11.postimage.org/oxwjte95b/spades.png'
}, {
text: 'Clubs',
value: 'Clubs',
iconUrl: 'http://s11.postimage.org/86b8an8wf/clubs.png'
}, {
// Dummy value for bug in Chrome, because last item can't be selected
text: '',
value: '_dummy',
iconUrl: ''
}],
getIconUrl: function (optValue) {
for (var i = 0; i < this.selectOptions.length; i++) {
var opt = this.selectOptions[i];
if (opt.value === optValue) {
return opt.iconUrl;
}
}
return '';
},
launch: function () {
Ext.create('Ext.form.Panel', {
fullscreen: true,
items: [{
xtype: 'selectfield',
label: 'Choose a color',
itemId: 'IconSelect',
usePicker: true,
options: PickerIcons.app.selectOptions,
defaultPhonePickerConfig: {
listeners: {
initialize: function () {
var slots = this.query('pickerslot');
Ext.each(slots, function (slot) {
slot.setItemTpl('<img class="pickerIcon"' +
'src="{[PickerIcons.app.getIconUrl(' +
'values.value)]}"></img> {text}');
});
},
change: function () {
// reconstruct the selectfield's change handler,
...