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.

  1. use labelwrap config option set true. avoid truncating text appears on selectfield initially. later when tap on selectfield; you've 2 choices. using picker or list. picker used if set true in usepicker config. if on tablet, desktop or mobile default list shown containing options. using labelwrap config not usefull if options displayed in list after tap on selectfield.

  2. 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 both list , selectfield display whole text neatly. override styles may affect appearance of other lists in app.

  3. 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 defined list. these decide appearance of list displayed on tap of selectfield. approach might sound dirty. it's useful, if want make drastic changes in appearance , behaviour.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -