-
22 Mar 2011 6:28 PM #1
[FIXED-EXTJSIV-264] Combo Templates
[FIXED-EXTJSIV-264] Combo Templates
I've not been able to get combo templates to work using 'tpl' .. maybe I'm doing that wrong or something has changed.
Either way though, something is broken in Ext as the example doesnt work. Look at the second combo, custom item templates. An abbreviation should be showing up there, and is not:
http://dev.sencha.com/deploy/ext-4.0...rm/combos.html
-
23 Mar 2011 6:32 PM #2
The old 'tpl' config has been changed, now you supply a getInnerTpl function as part of the listConfig configuration. The combos example was not updated to match this change (we're on it.)
I'm looking into the sorting issue.
-
24 Mar 2011 9:56 AM #3
I was trying to figure out what you meant by "listConfig". I notice the example does use innerTpl, and I'm guessing it should go inside of listConfig: {} but I could not find any reference to that.
Since the PR5 combo documents are broken I was looking at PR4 but listConfig is not indicated.
Could you please provide a quick example usage?
Thanks,
Luke
-
24 Mar 2011 10:01 AM #4
Nevermind, I suppose it is as easy as it sounds:
But what about the combo display template? The value in the combo when the list is not expanded?Code:this.myCombo = Ext.createWidget('combo', { ... listConfig: { getInnterTpl: function() { return "<div>... etc ...</div>"; } } });
-
24 Mar 2011 10:03 AM #5
Yup, you got it.
Sorry about the broken docs formatting, we're fixing that. In the meantime you can click through to the source code (click the class name at the top of the doc page) and read the doc comments in there.
-
3 May 2011 8:01 AM #6
Does this mean we have to return a string and not an XTemplate now?
-
11 May 2011 11:47 AM #7
Yes, the returned String will be part of an XTemplate definition, see Ext.view.BoundList:55
The default implementation just renders the displayField:Code:me.tpl = Ext.create('Ext.XTemplate', '<ul><tpl for=".">', '<li role="option" class="' + itemCls + '">' + me.getInnerTpl(me.displayField) + '</li>', '</tpl></ul>' );
Code:getInnerTpl: function(displayField) { return '{' + displayField + '}'; },
Currently I can't see a good way to override the entire template definition (tpl) which was possible in Ext3.
One should also not get confused by the docs inherited from AbstractView - itemTpl and tpl config options do not apply to BoundList since it overrides base class functionality as shown above.
-
11 May 2011 12:06 PM #8
It's not very clean, but you could do:
1) Extend BoundList
2) Override initComponent
3) this.callParent(), then set this.tpl to a new XTemplate based on
4) Extend ComboBoxPHP Code:
me.tpl = Ext.create('Ext.XTemplate',
'<ul><tpl for=".">',
'<li role="option" class="' + itemCls + '">' + me.getInnerTpl(me.displayField) + '</li>',
'</tpl></ul>'
);
5) override CreatePicker to basically copy it, and change the Ext.create for the picker to use your BoundList as the picker
HTH
stevil
-
11 May 2011 12:08 PM #9
Or, if you want this everywhere, you could just override BoundList and ComboBox. Easier, but not long on style points...
stevil
-
11 May 2011 12:49 PM #10
Thx for your reply.
Both solutions massively violate my coding conduct
When I ran into this yesterday, I decided to rewrite my CSS and go with the standard markup instead. Everything else gave me the willies.
Haven't even looked as far as how to use a custom BoundList implementation in ComboBox. There should really be an easy way to override the implementing class when using composition. Duplicating the createPicker code could easily be avoided if the code delegated instantiation to a factory method , or - facilitating the Ext4 class loading pattern - just allow configuration of the class name as a config property.
Admittingly, reconfiguring the tpl in BoundList after callParent wouldn't be THAT bad - just not very nice since we execute code and then throw away the result.
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
[FIXED-EXTJSIV-240] ReadOnly combo bug
By wki01 in forum Ext:BugsReplies: 1Last Post: 26 Mar 2011, 8:42 PM -
Combo with Templates and Ajax with RPC proxy
By cutout33 in forum Ext GWT: DiscussionReplies: 5Last Post: 2 Mar 2011, 3:08 PM -
Combo with Templates and Ajax: on mouse paste
By Chamil in forum Ext 1.x: Help & DiscussionReplies: 0Last Post: 19 Jan 2010, 10:12 PM -
Combo with Templates and Ajax
By gte619n in forum Ext GWT: Help & Discussion (1.x)Replies: 0Last Post: 2 Apr 2009, 5:27 PM -
Help with combo box and templates
By josh803316 in forum Ext 2.x: Help & DiscussionReplies: 9Last Post: 18 Mar 2009, 12:08 AM


Reply With Quote