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
labelwrapconfig option set true. avoid truncating text appears onselectfieldinitially. later when tap on selectfield; you've 2 choices. usingpickerorlist.pickerused if set true inusepickerconfig. if on tablet, desktop or mobile defaultlistshown containing options. usinglabelwrapconfig not usefull if options displayed inlistafter 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
labelwrapconfig set true make bothlist,selectfielddisplay 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 -gettabletpickergenerated 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,clsconfig. here both options set styles definedlist. these decide appearance oflistdisplayed on tap of selectfield. approach might sound dirty. it's useful, if want make drastic changes in appearance , behaviour.
Comments
Post a Comment