PDA

View Full Version : Duplicating template in Combobox



cnfedx
14 Apr 2014, 8:27 PM
When using viewConfig on combobox to customise dropdown template I'm having issues with instead of overwriting existing template content on each dropdown refresh I get duplicated template (whenever I type in any text in combobox).
This is a sample config I use:
listConfig: {
tpl: '<div><div class="AddNewitem" onclick="NewUnit();"><a>Add new Unit</a></div><ul><tpl for="."><li class="x-boundlist-item">{Unit}</li></tpl></ul></div>',
itemSelector: 'li.x-boundlist-item'
}

This part gets duplicated in dropdown on every dropdown refresh:
<div><div class="AddNewitem" onclick="NewUnit();"><a>Add new Unit</a></div><ul></ul></div>

Please advice if there is a new way to achieve this sort of customisation with 5.0 or this is just a bug?

mitchellsimoens
18 Apr 2014, 6:05 AM
I'm not able to reproduce with this example:


var states = new Ext.data.Store({
fields : ['abbr', 'name'],
data : [
{ abbr : 'AL', name : 'Alabama' },
{ abbr : 'AK', name : 'Alaska' },
{ abbr : 'AZ', name : 'Arizona' }
]
});

new Ext.form.field.ComboBox({
fieldLabel : 'Choose State',
store : states,
queryMode : 'local',
displayField : 'name',
valueField : 'abbr',
renderTo : Ext.getBody(),
listConfig : {
tpl : '<div>Hello</div>' + //this only shows once as expected
'<tpl for=".">' +
'<li role="option" unselectable="on" class="x-boundlist-item">{name}</li>' +
'</tpl>'
}
});

cnfedx
18 Apr 2014, 7:00 AM
Please click on combobox in your sample to show options. Then start typing any text in the combobox text field. then open combobox dropdown again.