-
7 Feb 2012 7:36 AM #1
Unanswered: Select Field and tpl
Unanswered: Select Field and tpl
I noticed in the documentation that the Ext.field.Select has a tpl attribute. I'm unclear as to what it does, however, I was wondering if there was a way to use it instead of the displayField value? If not is there another option that might allow for HTML when displaying the selected item?
No longer a Newbie
-
7 Feb 2012 9:29 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 436
- Answers
- 3108
tpl is inherited and should be removed from the Select field.
Currently you would have to override the getTabletPicker method (or define your own on the listPanel property) to access the list. Currently, the getTabletPicker method looks like:
So you would have to override it and change the itemTpl on the list. As I said, you could also create a Panel with a list and put it on the listPanel property of the Select field.Code:getTabletPicker: function() { if (!this.listPanel) { this.listPanel = Ext.create('Ext.Panel', { top : 0, left : 0, 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() + '}</span>', listeners: { select : this.onListSelect, itemtap: this.onListTap, scope : this } } }); } return this.listPanel; },
Going further, there is going to be a new defaultTabletPickerConfig that you can use but you would have to do this:
The issue I see there is the scoping of the listeners. If that doesn't work then you would have to define your own getDefaultTabletPickerConfig method on the select field:Code:defaultTabletPickerConfig : { items : { xtype: 'list', store: this.getStore(), itemTpl: '<span class="x-list-label">{' + this.getDisplayField() + '}</span>', listeners: { select : 'onListSelect', itemtap: 'onListTap' } } }
Code:getDefaultTabletPickerConfig : function() { return { items : { xtype: 'list', store: this.getStore(), itemTpl: '<span class="x-list-label">{' + this.getDisplayField() + '}</span>', listeners: { select : this.onListSelect, itemtap: this.onListTap, scope: this } } }; }Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Feb 2012 10:33 AM #3
Looking on the code, couldn't I simply override the getDisplayField method?
No longer a Newbie
-
7 Feb 2012 10:42 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 436
- Answers
- 3108
If you take into account that this.getDisplayField() is wrapped with '{' and '}' already so you are restricted a little.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote