In the ExtJS 3.3.1, I tried to make comboBox to multi select , but it doesn't work.
Please help.
var mArray = new Array("ALL", "AAA", "BBB");
var mCombo = new Ext.form.ComboBox({ id: 'ID', fieldLabel: 'ID',
triggerAction: 'all',
height: 100, width: 163,
multiSelect: true,
store: mArray
});
Ext.getCmp('mCombo').setValue("ALL");
There isn't a config option like multiSelect in Ext.form.ComboBox.
To get desired functionality you either need to develop a multiselect combobox by your own or use one of existing alternatives, like Ext.ux.form.CheckboxCombo, Ext.ux.form.SuperBoxSelect and Ext.ux.form.LovCombo.
return new Ext.form.ComboBox({
fieldLabel: fieldLabel,
hiddenName: name,
store: store ,
valueField:'value',
displayField:'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select '+fieldLabel+' ...',
selectOnFocus:true,
allowBlank:allowBlank,
forceSelection : true,
disabled:disabled,
multiSelect:true,
width:200,
id:id,
listeners:{
change : function( frm, newValue, oldValue ) {
doRenderTL();
}
},
renderTo: Ext.get( renderTo )
});
Related
I am trying to set a default value in a ComboBox in ExtJS 3.4 I have tried to set value: 'Standard' in the ComboBox config, but that only places a string in the box. I did some digging around and tried to setup the afterrender function, but still haven't gotten it to populate. The goal is to get the box to actually select the value and populate the box with the Json data, so that the user is able to select from subsequent ComboBoxes.
var hatComboStore = new Ext.data.JsonStore({
autoLoad: true,
fields: [
'BIN_ID',
'BIN_DESC'
],
baseParams: {
method: 'post'
},
url: 'json_bin_hat.php'
});
var hatCombo = new Ext.form.ComboBox({
allowBlank: false,
autoSelect: true,
displayField: 'BIN_DESC',
emptyText: 'Select a hat...',
fieldLabel: 'Hat',
forceSelection: false,
hiddenName: 'hatId',
itemId: 'hatId',
listEmptyText: 'No records found',
listeners: {
afterrender: function(combo, record, index) {
var hat = combo.getValue();
binCombo.store.baseParams.hat = hat;
},
select: function(combo, record, index) {
var hat = combo.getValue();
binCombo.store.baseParams.hat = hat;
},
focus: function(combo) {
binCombo.clearValue();
}
},
mode: 'remote',
msgTarget: 'side',
name: 'hatDesc',
store: hatComboStore,
submitValue: true,
triggerAction: 'all',
valueField: 'BIN_ID'
});
Anyone have any ideas? Thanks for your help!
I've got it to work using an override method.
Basically, the displayValue is what I wanted to display ('Standard') and the value is what I wanted to execute (value: 1). Apparently, the remote store is a little tricky to work with, so that's why the override was necessary.
var hatComboStore = new Ext.data.JsonStore({
autoLoad: true,
fields: [
'BIN_ID',
'BIN_DESC'
],
baseParams: {
method: 'post'
},
url: 'json_bin_hat.php'
});
var hatCombo = new Ext.form.ComboBox({
allowBlank: false,
autoSelect: true,
displayField: 'BIN_DESC',
displayValue: 'Standard',
emptyText: 'Select a hat...',
fieldLabel: 'Hat',
forceSelection: false,
hiddenName: 'hatId',
itemId: 'hatId',
listEmptyText: 'No records found',
listeners: {
afterrender: function(combo, record, index) {
var hat = combo.getValue();
binCombo.store.baseParams.hat = hat;
},
select: function(combo, record, index) {
var hat = combo.getValue();
binCombo.store.baseParams.hat = hat;
},
focus: function(combo) {
binCombo.clearValue();
}
},
mode: 'remote',
msgTarget: 'side',
name: 'hatDesc',
store: hatComboStore,
submitValue: true,
triggerAction: 'all',
valueField: 'BIN_ID'
value: 1
});
//Override method to default hatCombo value to 'Standard' while underlying value = 1
Ext.override(Ext.form.ComboBox, {
initValue: Ext.form.ComboBox.prototype.initValue.createSequence(function() {
if (this.mode == 'remote' && !!this.valueField && this.valueField != this.displayField && this.displayValue) {
if (this.forceSelection) {
this.lastSelectionText = this.displayValue;
}
this.setRawValue(this.displayValue);
}
})
});
Looks like the value prop is not working for remote stores. Probably the combo is rendered before the store has loaded. You can set the value after the store has loaded.
This works for me (tested as an ExtJS 3.4 fiddle).
var hatComboStore = new Ext.data.JsonStore({
autoLoad: true,
fields: [
'id',
'title'
],
url: 'https://jsonplaceholder.typicode.com/todos'
});
var hatCombo = new Ext.form.ComboBox({
fieldLabel: 'Hat',
store: hatComboStore,
displayField: 'title',
valueField: 'id',
mode: 'local',
submitValue: true,
triggerAction: 'all',
// Apparently does not work with remote store.
// value: '1'
});
hatComboStore.on('load', () => hatCombo.setValue('1'));
new Ext.form.FormPanel({
items: hatCombo,
renderTo: Ext.getBody()
});
see example of setting default value:
Combo config:
{
triggerAction: 'all',
id: 'dir_id',
fieldLabel: 'Direction',
queryMode: 'local',
editable: false,
xtype: 'combo',
store : dirValuesStore,
displayField:'name',
valueField:'id',
value: 'all',
width: 250,
forceSelection:true
}
source: Extjs 4 combobox default value
I am new in ExtJS and now I am making an editable grid with a combox column. I am having a problem in displaying my chosen data from the combobox. May someone help me. Screenshot is provided below.
Link provided.. :))
My combobox code...
Data:
var farms = new Ext.data.ArrayStore({
fields: ['id', 'farms'],
data : [
['1', 'DVZ'],
['2', 'SSK'],
['3', 'LNA'],
['4', 'NSK']
]
});
Combobox..
header : 'Location',
width : 130,
fixed : true,
hideable : false,
dataIndex: 'farms',
editor : {xtype:'combo',
store: farms,
displayField:'farms',
valueField: 'id',
queryMode: 'local',
typeAhead: true,
triggerAction: 'all',
lazyRender: true,
emptyText: 'Select location...',
autoload: true
}
it's might be that your dataindex value in grid config, not same like you value field in combobox config
for example, look at this config on "Responsible" field
columns: [
{ header: 'ID', dataIndex: 'id', width: 50, hidden: true, sortable: true },
{header: 'Responsible',
width: 175,
sortable: true,
renderer: title_respU_D1,
dataIndex: 'resp_user_name'
,editor: new Ext.form.ComboBox({
typeAhead: true,
triggerAction: 'all',
store: app_responsibleStore,
mode: 'remote',
valueField: 'resp_user_name',
displayField: 'resp_user_name',
listClass: 'x-combo-list-small'
})
}
]
You may be missing some "config" in editor config of items in grid panel.
I hope you may missed typeAhead config.
Please refer below link of sencha example
http://docs.sencha.com/extjs/4.0.7/extjs-build/examples/grid/cell-editing.html
Thanks.
I have added quicktip(tooltip) for the combox by using tpl as below,
'<tpl for="."><div ext:qtip="{text}" class="x-combo-list-item">{text}</div></tpl>'
But after adding this, the combobox doesn't mark (in blue) the selected entries. ie, Before i am adding the tooltip, the selected entries can be seen as marked or selected (as blue color for me). But now its not working(the selected enitries are not seeing as selected).
Here is my code,
{
name : name,
hideOnSelect : false,
triggerAction : 'all',
mode : 'local',
width : size,
tpl :'<tpl for="."><div ext:qtip="{text}" class="x-combo-list-item">{text}</div></tpl>',
store : new Ext.data.SimpleStore({
id : 0,
fields : ['value','text'],
data : data
}),
listWidth : 400,
valueField : 'value',
displayField : 'text'
}
<---before
<---after
Any help is must appreciated...Thank you.
displayTpl should work too:
{
name: name,
hideOnSelect: false,
triggerAction: 'all',
mode: 'local',
width: size,
store: new Ext.data.SimpleStore({
id: myCombo,
fields: ['value','text'],
data: data
}),
listWidth: 400,
valueField: 'value',
displayField: 'text',
displayTpl: '<tpl for="."><div ext:qtip="{text}">{text}</div></tpl>'
}
UPDATE
Found the issue! You had to init the QuickTips first. The rest of your code was fine! Here is a working fiddle
Ext.QuickTips.init();
var cb = new Ext.form.ComboBox({
name: name,
hideOnSelect: false,
triggerAction: 'all',
mode: 'local',
width: 200,
store: new Ext.data.JsonStore({
id: "myCombo",
fields: ['value', 'text'],
data: [
{ value: 1, text: 'one'},
{ value: 2, text: 'two'},
{ value: 3, text: 'three'}
]
}),
listWidth: 250,
valueField: 'value',
displayField: 'text',
renderTo: Ext.getBody(),
tpl: '<tpl for="."><div ext:qtip="{text}" class="x-combo-list-item">{text}</div></tpl>'
});
can you try this...
{
name : name,
hideOnSelect : false,
triggerAction : 'all',
mode : 'local',
width : size,
store : new Ext.data.SimpleStore({
id : myCombo,
fields : ['value','text'],
data : data
}),
listWidth : 400,
valueField : 'value',
displayField : 'text',
listConfig: {
getInnerTpl: function() {
return '<div data-qtip="{text}">{value}</div>';
}
}
}
I have a combobox I can get all data I want but when i enter a letter, the data should be choosen in combobox
forexample,my variables: ankara, aston, amasya, bolu, berlin, ....
When i enter 'a' letter ankara should be selected. if i enter 'as' word aston should be selected how can i do it? thanks..
new Ext.form.ComboBox({
id : 'il3',
fieldLabel: dil('B Merkez İli'),
hiddenName : 'b_il_id_hid',
name : 'b_il_id',
store: ilStore,
valueField:'id',
queryMode: 'local',
displayField:'isim',
typeAhead: true,
triggerAction: 'all',
emptyText: dil('İl Seçiniz...'),
selectOnFocus:true,
anchor: '100%',
listeners:{
select:{
fn:function(combo, value) {
var modelCmp = Ext.getCmp('ilce3');
modelCmp.setDisabled(false);
modelCmp.store.removeAll();
modelCmp.setValue('');
modelCmp.store.reload({
params: {
id: combo.getValue()
}
});
}
}
},
allowBlank:false
})
store:
var ilStore = new Ext.data.JsonStore({
root: 'rows',
totalProperty: 'results',
idProperty: 'id',
remoteSort: true,
autoLoad : true,
fields: [
'id', 'isim'
],
baseParams:{
'tip':'il'
},
listeners:{
beforeload:function(dukan,nesne){
var modelCmp = Ext.getCmp('id-faz-yon1');
dukan.baseParams.faz = modelCmp.getValue();
},
keyup: function() {
this.store.filter('isim', this.getRawValue(), true, false);
}
},
proxy: new Ext.data.HttpProxy({
url: 'phps/sabit_agac_arama.php?lang=dil(lang)',
method : 'POST'
})
});
Add queryMode: 'local', to the config.
See the example in the API
Hi i have a formpanel with remote combobox, the store is jsonstore and is get from webservices with paging results, everything is well, but when you pick an option form the combo always pick the first one, you can pick the third but the combo choose the first option i don't know the reason for this the configuration for the combo is this:
{
xtype: 'combo',
fieldLabel: 'Sitio Interés',
anchor: '100%',
triggerAction: 'all',
store: dsPuntos,
mode: 'remote',
displayField: "Nombre",
valueField: "Id",
typeAhead: false,
width: 222,
hideLabel: true,
allowBlank: false,
id: 'cboDato',
editable: true,
pageSize: 20,
minChars: 0,
hideTrigger: true,
//enableKeyEvents: true,
emptyText: 'Escriba un sitio de interés',
tpl: '<tpl for="."><div class="x-combo-list-item">{Nombre} - {Municipio}</div></tpl>',
listeners: {
scope: this,
specialkey: function (f, e) {
if (e.getKey() == e.ENTER) {
Ext.getCmp('btnConsultar').handler.call(Ext.getCmp('btnConsultar').scope);
}
}
}
},
and the store is here:
var dsPuntos = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: 'Services/MapService.svc/GetSitiosInteres',
method: 'GET'
}),
root: 'd.rows',
totalProperty: 'd.total',
id: 'Id',
fields: ['Nombre', 'Municipio', 'Id']
});
Thanks
Your store config is a little off. It should be idProperty instead of id. Also check the json coming from the server. Make sure that the id are unique.