PDA

View Full Version : autoselect Combox



gameboy87
5 Apr 2012, 5:02 AM
An excerpt from the documentation of combobox is below. But how to implement to my combobox ?



From extjs/docs/source/ComboBox.html#Ext-form-field-ComboBox-cfg-autoSelect





/** * @private * If the autoSelect config is true, and the picker is open, highlights the first item. */ doAutoSelect: function() { var me = this, picker = me.picker, lastSelected, itemNode; if (picker && me.autoSelect && me.store.getCount() > 0) { // Highlight the last selected item and scroll it into view lastSelected = picker.getSelectionModel().lastSelected; itemNode = picker.getNode(lastSelected || 0); if (itemNode) { picker.highlightItem(itemNode); picker.listEl.scrollChildIntoView(itemNode, false); } } },






Please help !

scottmartin
5 Apr 2012, 12:42 PM
This is taken from the API docs .. it opens picker and selected first item.



// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"Arizona"}
//...
]
});

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody()
});


Is the not working, or did I not understand your question?

Regards,
Scott.

gameboy87
5 Apr 2012, 7:29 PM
Scott, I am asking about how to create picker for combobox manually by a user ? (sorry for not mentioning properly).Because I have implement in 'load' listener event of combo to set the default from the DB and to highlight the selected value on clicking the combobox(The list in the combobox shows the setValue in highlight on second click of the combo.)



This is taken from the API docs .. it opens picker and selected first item.



// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"Arizona"}
//...
]
});

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody()
});


Is the not working, or did I not understand your question?

Regards,
Scott.