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.
Related
I'm facing issue of firing edit event using cell editor in Ext Js 3.4.
I'm trying to achieve triggering an ajax call upon a cell edited after pressing 'Enter'.
For now, I just replaced with console.log('hi') but it doesn't show anything after I pressed 'Enter'.
I'm not sure what's wrong in my code. Appreciate if someone can point it out. Thanks.
var grid = new Ext.grid.EditorGridPanel({
store: api_store,
loadMask: true,
clicksToEdit: 1,
tbar: [{
text: 'Create',
handler: function () { }
}],
columns: [
{
id: 'name',
header: 'Key Name',
width: 300,
sortable: true,
dataIndex: 'name',
editor: {
xtype: 'textfield',
allowBlank: false,
listener: {
edit: function (el) {
console.log('hi');
}
}
}
},
{
header: 'Key Value',
width: 500,
sortable: false,
dataIndex: 'key'
}
],
sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
viewConfig: {
forceFit: true
},
height: 210,
stripeRows: true,
height: 350,
title: 'Keys'
});
Solution:
Use EditorGridPanel afteredit event:
afteredit(e)
Fires after a cell is edited. The edit event object has the following
properties
grid - This grid
record - The record being edited
field - The field name being edited
value - The value being set
originalValue - The original value for the field, before the edit.
row - The grid row index
column - The grid column index
Parameters:
e : Object An edit event (see above for description)
Example:
Ext.onReady(function () {
var api_store = new Ext.data.ArrayStore({
fields: ['key', 'name'],
data: [
['1', 'Name1'],
['2', 'Name2'],
['3', 'Name3']
]
});
var grid = new Ext.grid.EditorGridPanel({
renderTo: Ext.getBody(),
store: api_store,
loadMask: true,
clicksToEdit: 1,
tbar: [{
text: 'Create',
handler: function () { }
}],
listeners: {
afteredit: function(e) {
console.log('After edit. Column: ' + e.field);
}
},
columns: [
{
id: 'name',
header: 'Key Name',
width: 300,
sortable: true,
dataIndex: 'name',
editor: {
xtype: 'textfield',
allowBlank: false
}
},
{
header: 'Key Value',
width: 500,
sortable: false,
dataIndex: 'key'
}
],
sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
viewConfig: {
forceFit: true
},
height: 210,
stripeRows: true,
height: 350,
title: 'Keys'
});
});
In ExtJs 3.4 I have a TabPanel with two tabs, the second tab contains a FormPanel, what contains a ButtonGroup. If the second tab is active, when I load the page, then everything is good, but when the first tab is active and I switch to the second, then there is no button in the button group, just the label. Here is the code:
var tabs = new Ext.TabPanel({
renderTo: 'tabs',
width:500,
forceLayout: true,
activeTab: 0,
deferredRender: false,
defaults:{autoHeight: true},
items:[
{contentEl:'tab1', title: 'Tab1'},
{contentEl:'tab2', title: 'Tab2'}
]
});
var form = new Ext.form.FormPanel({
width : 400,
autoHeight: true,
renderTo: 'form',
bodyStyle: 'padding: 5px',
items: [
{
xtype: 'buttongroup',
fieldLabel: 'Label',
items:
[
{
xtype: 'button',
text: 'Find By User',
width: 100,
scope: this,
handler: this.handleFind
},
{
xtype: 'button',
text: 'Find All',
width: 100,
scope: this,
handler: this.handleFindAll
}
]
}
]
});
I set the deferredRender: false and forceLayout: true, also tried the hideMode: 'offsets', but these didn't help.
Well, I add the hideMode: 'offsets' to the defaults of the TabPanel and it works fine. I did the same a few years ago without significant result.
Remove renderTo: 'form' and look at the working code here:
var form = new Ext.form.FormPanel({
width: 400,
autoHeight: true,
//renderTo: 'form',
bodyStyle: 'padding: 5px',
items: [{
xtype: 'buttongroup',
fieldLabel: 'Label',
items: [{
xtype: 'button',
text: 'Find By User',
width: 100,
scope: this,
handler: this.handleFind
}, {
xtype: 'button',
text: 'Find All',
width: 100,
scope: this,
handler: this.handleFindAll
}]
}]
});
var tabs = new Ext.TabPanel({
renderTo: 'tabs',
width: 500,
forceLayout: true,
activeTab: 0,
//deferredRender: false,
height: 300,
defaults: {
autoHeight: true
},
items: [{
contentEl: 'tab1',
title: 'Tab1'
}, {
//contentEl: 'tab2',
title: 'Tab2',
items: [form]
}]
});
I have this field:
{
xtype: 'filefield',
labelAlign: 'top',
id: 'fileAllegato',
hidden: true,
margin: '0 15 5 10',
fieldLabel: 'Allegato',
allowBlank: false,
blankText:'Il campo è obbligatorio!',
typeAhead: true,
selectOnFocus: true,
anchor: '100%',
buttonText: 'Allega'
}
When I load the file, I want to save it in db. The field does not belong to a form and, therefore, I can not do the submit. How can I do?
You can create a dummy form (without even displaying it). Something like
var f = Ext.create('Ext.form.Panel', {
items: [ your filefield item ]
})
And then do submit.
items: [{
xtype: 'filefield',
name: 'file',
fieldLabel: 'File',
labelWidth: 50,
anchor: '100%',
buttonText: 'Select File...'
}],
Live demo is here
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.
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.