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.
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'm a beginner on js and ExtJS 3.4, I'm trying to use Ext.form.ComboBoxin a Ext.window to show the list of js objects (layers).
The problem is when I create the window the first time and I click on the combobox trigger I get my layers list correctly, but when I remove or add a layer and I click again on the trigger the store don't update and I find the same list.
Can you please help me to find a solution to this problem, for example when I click on the trigger it will update and load the new list store ?
Any suggestion is welcome.
CODE SNIPPET
// The "ImageField" is an item witch is called on the return of the methode "createWindow" ...
createWindow: function() {
ImageField = new Ext.form.ComboBox(Ext.apply({
name: "Image_ref",
fieldLabel: "Image Input (Required)",
emptyText: "Select your Image",
xtype: 'combo',
forceSelection: true,
editable: true,
allowBlank: true,
triggerAction: 'all',
mode: 'local',
valueField: 'value',
displayField: 'text',
labelWidth: 300
width: 250,
id: 'myCombo',
hideLabel: false,
lazyRender: false,
lazyInit: false,
mode: 'local',
triggerAction: 'all',
store: new Ext.data.SimpleStore({
autoLoad: true,
autoDestroy: true,
fields: ['text', 'value'],
data: layer_liste_WCS // is a liste of js objects
}),
listeners: {
beforequery: function(qe) {
// console.log(qe);
qe.cancel = true;
addComboxFieldItemsWCS(); // Run this methode to get "layer_liste_WCS" witch is liste of data
var actionComboBox = Ext.getCmp('myCombo');
.
.
.
.
.
.
// I don't know how to do to reload the store after runing the methode "addComboxFieldItemsWCS"
}
}
}, base));
return new Ext.Window({
closable: true,
resizable: false,
shadow: false,
closeAction: 'hide',
region: "center", //"north","south","east","west"
width: 480,
height: 190,
iconCls: 'wind_icon',
plain: true,
layout: 'border',
buttonAlign: 'right',
layout: 'fit',
listeners: {
show: function() {
this.el.setStyle('left', '');
this.el.setStyle('top', '');
}
},
items: [{
region: 'center',
xtype: 'tabpanel',
activeTab: 0,
width: 50,
height: 20,
items: [{ // we will declare 3 tabs
title: 'Datas Inputs',
closable: false,
iconCls: 'input_icon',
active: true,
items: [{
xtype: 'form',
autoWidth: true,
labelWidth: 185,
bodyStyle: "padding:10px;",
items: [
ImageField,
]
}]
}]
}],
});
},
I'm late for the answer but I take a chance.
Do you have an ajax call in addComboxFieldItemsWCS?
Put this code on your callback if you can:
Ext.getCmp('myCombo').getStore().loadData(layer_liste_WCS, false);
For your information, The false parameter is to replace existing data.
Hope this help.
I have an ExtJs combobox. Its store loaded using JSON (using my store). I want to load all the values to the store, and then filter them with the text entered in the combo's textfield.
I don't want my combo to reload its store every time I type something. How can I do that?
And other thing that then I try to select element from combobox first time it's reload data from server.
PS: listener in my store for select first element of data from server.
Thanks.
Here's my store class :
Ext.define('KP.store.account.street', {
extend: 'Ext.data.Store',
model: 'KP.model.account.combo',
autoLoad: true,
proxy: {
type: 'ajax',
api: {
read: '/account/combostreetdata'
},
reader: {
type: 'json',
root: 'combolist',
successProperty: 'success',
totalProperty: 'total'
}
},
listeners: {
'load': function (street_list) {
var street_combo = Ext.getCmp('street');
street_combo.select(street_list.getAt(0));
}
}
});
My view:
{
id: 'street',
xtype: 'combobox',
width: 700,
name: 'street',
editable: true,
mode: 'local',
typeAhead: true,
emptyText: '?????',
fieldLabel: '???',
labelWidth: 120,
size: 72,
x: 20,
y: 180,
displayField: 'string_value',
valueField: 'long_key',
store: street_list
},
You have a ComboBox config error.
Not mode: 'local', but queryMode: 'local',.
I use such a fields in my combos:
queryMode: 'local',
forceSelection: true,
Typeahead works fine, no data loads during typeahead.
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 )
});
I have a combo B that gets loaded by other combo A (triggered by 'select' listener)
once B is populated, I see all items but now from drop-down in Combo B,
I'm force to select the first item with mouse
I can select other item only by typing
Please help!!!!
code for Combo A
{
xtype: 'combo',
displayField: 'value',
emptyText: 'Please select A first',
fieldLabel: 'Combo A',
id: 'comboA',
maxHeight: 240,
mode: 'local',
triggerAction: 'all',
typeAhead: true,
typeAheadDelay: 100,
valueField: 'id',
store: new Ext.data.JsonStore({
url: '/cgi-bin/server.cgi',
fields: ['id', 'name'],
baseParams: {
action: 'getAList'
},
autoLoad: true,
root: 'aList'
}),
listeners: {
'select': {
fn: function(){
var comboB = Ext.getCmp('comboB');
comboB.clearValue();
comboB.store.removeAll();
comboB.store.reload({
params: {
id: this.getValue()
}
})
}
}
}
}
Code for combo B:
{
xtype: 'combo',
displayField: 'item',
editable: true,
emptyText: 'Select a Combo A first',
fieldLabel: 'Combo B',
id: 'comboB',
lazyInit: true,
maxHeight: 240,
mode: 'local',
triggerAction: 'all',
typeAhead: true,
valueField: 'id',
width: 220,
store: new Ext.data.JsonStore({
url: '/cgi-bin/server.cgi',
root: 'bList',
autoLoad: false,
fields: ['id,', 'item'],
baseParams: {
action: 'getBList'
},
listeners: {
'beforeload': function(){
Ext.getCmp('comboB').disable();
},
'load': function(){
Ext.getCmp('comboB').enable();
}
}
})
}
Not sure what exactly is wrong here but I suspect this piece in your comboA is not getting fired as expected -
comboB.store.reload({
params: {
id: this.getValue()
}
})
So comboB is still disabled. when you click on the comboB trigger, it loads the store and the comboB's store's load listener is kicking in as expected to enable the combo.
Try putting some debug statements or stepping through the piece of code above.