extjs - how to wrap text of selectfield option in sencha touch 2 -
i'am trying display sencha touch 2 selectfield
long option text text gets truncated ellipsis, very long option t...
.
how display couple lines in 1 option?
code:
{ xtype: 'selectfield', options:[ { text: 'very long option wish splint 2 separate lines', value: 0 }, { text: 'another long option wish splint 2 separate lines', value: 1 } ] }
i've tried using \n
, <br/>
not working.
there 3 2 ways this.
use
labelwrap
config option set true. avoid truncating text appears onselectfield
initially. later when tap on selectfield; you've 2 choices. usingpicker
orlist
.picker
used if set true inusepicker
config. if on tablet, desktop or mobile defaultlist
shown containing options. usinglabelwrap
config not usefull if options displayed inlist
after tap on selectfield.use following css override avoid truncating.
.x-list-item-label{ height: 100% !important; } .x-list-label{ white-space: pre-wrap !important; }
this override along above mentioned
labelwrap
config set true make bothlist
,selectfield
display whole text neatly. override styles may affect appearance of other lists in app.third approach can override
ext.field.select
, create custom select field. in style, need override following method -gettabletpicker
generated list displayed on tap of selectfield. code st source fallows -gettabletpicker: function() { var config = this.getdefaulttabletpickerconfig(); if (!this.listpanel) { this.listpanel = ext.create('ext.panel', ext.apply({ centered: true, modal: true, cls: ext.basecssprefix + 'select-overlay', layout: 'fit', hideonmasktap: true, items: { xtype: 'list', store: this.getstore(), itemtpl: '<span class="x-list-label">{' + this.getdisplayfield() + ':htmlencode}</span>', listeners: { select : this.onlistselect, itemtap: this.onlisttap, scope : } } }, config)); } return this.listpanel; }
check out line
itemtpl
,cls
config. here both options set styles definedlist
. these decide appearance oflist
displayed on tap of selectfield. approach might sound dirty. it's useful, if want make drastic changes in appearance , behaviour.
Comments
Post a Comment