mardi 21 octobre 2014

Combobox's view not defined? Trying to set a value. EXTJS 4.0.7

Resuming:

I have an app that displays 3 combos and 1 textbox. The first combo is like "Country", doesnt depend on anything. The second, depends on Country (to show States), and the third depends on the second one.


I have 2 events defined in the store: ancestorValueChange and afterComboRender.


After all combos are defined (and their stores), I search for the combos that DO NOT DEPEND ON ANYONE (like Country), then on these I call store.load() and inside it I call the event afterComboRender, which tries to change the value for a value I have in a variable and that exists in the store records).


So, afterComboRender should change the value (which is in the form '30-2035756720-4', string, and ID and Description are the same.)


When I call afterComboRender and inside it I call combo.setValue('30-2035756720-4'), it reaches a place that says "view is undefined".


I'd like to know if my approach is bad.



Code:




onSelectChange: function(record, isSelected, suppressEvent, commitFn) {
var me = this,
view = me.view,
eventName = isSelected ? 'select' : 'deselect';

if ((suppressEvent || me.fireEvent('before' + eventName, me, record)) !== false &&
commitFn() !== false ){ //&& Ext.isDefined(view)) {

if (isSelected) {
view.onItemSelect(record); <------ view is not defined.
} else {
view.onItemDeselect(record);
}

if (!suppressEvent) {
me.fireEvent(eventName, me, record);
}
}
},

destroy: function(){
Ext.destroy(this.keyNav);
this.callParent();
}
});

My code:



Code:



var idOptionsStore = getStore(idOptionsModel, idOptionsModel, {
autoLoad: !hasDependency,
comboId: fldId
});
if( hasDependency ) {
disabled = true;
queryMode = 'remote';
ancestorId = wfId + '-' + prefijo + '-' + dependsOn;

idOptionsStore.addEvents( {'ancestorValueChange':true} );

idOptionsStore.addListener(
'ancestorValueChange',
function(newValue) {
var getParamsString = '';
for (var key in newValue.ancestorsValues) {
if( newValue.ancestorsValues.hasOwnProperty(key) ) {
var ancestorId = key.substr(key.lastIndexOf('-')+1);
var ancestorValue = newValue.ancestorsValues[key];
var sectoresEnArrayParaURL = '';
getParamsString += "&ancestors["+ancestorId+"]="+ancestorValue;
}
}
for(var i=0; i < currentusersector.length; i++) {
sectoresEnArrayParaURL += '&sectores['+i+']='+currentusersector[i];
}
getParamsString += sectoresEnArrayParaURL;
index = this.proxy.url.indexOf('&ancestor');
if( index > 0 ) {
this.proxy.url = this.proxy.url.substr(0, index) + getParamsString;
} else {
this.proxy.url = this.proxy.url + getParamsString;
}
},
idOptionsStore
);
}
idOptionsStore.addEvents( {'afterComboRender': true} );
idOptionsStore.addListener(
'afterComboRender',
function (eOpts) {
//eOpts = operation.options, bug de ExtJS.
/** Cargar primer valor en Combos **/
if (typeof eOpts.combo != 'undefined') {
var combo = eOpts.combo;
if (typeof combo.autoSelectFirst !== 'undefined' && combo.autoSelectFirst) {
var primerValor = this.getStore().getAt(0);
if (typeof primerValor !== 'undefined') {
combo.setValue(primerValor.get('id'));
}
}
if (combo.mantenerValor && combo.valorAnterior) {
combo.setValue(combo.valorAnterior);
}
}
});


**********************
**********************

After the loop that adds all fields / combos


for (var i=0; i < campos.length;i++) {
if ( campos[i].getXType() == 'combobox' && ! campos[i].hasDependency ) {
campos[i].getStore().load({
scope: campos[i],
callback: function()
{
this.getStore().fireEvent('afterComboRender', {combo: this});
}
})
}
}

**************
*********************

Stack:

Main page
> onSelectChange, ext-all-debug-w-comments.js, Línea 86265
doSingleSelect, ext-all-debug-w-comments.js, Línea 85886
doSelect, ext-all-debug-w-comments.js, Línea 85771
select, ext-all-debug-w-comments.js, Línea 85746
syncSelection, ext-all-debug-w-comments.js, Línea 105815
setValue, ext-all-debug-w-comments.js, Línea 105690
Anonymous function, index.php, Línea 1413
fire, ext-all-debug-w-comments.js, Línea 16976
continueFireEvent, ext-all-debug-w-comments.js, Línea 21172
fireEvent, ext-all-debug-w-comments.js, Línea 21145
callback, index.php, Línea 1757
callback, ext-all-debug-w-comments.js, Línea 8911
onProxyLoad, ext-all-debug-w-comments.js, Línea 67169
processResponse, ext-all-debug-w-comments.js, Línea 39586
Anonymous function, ext-all-debug-w-comments.js, Línea 40061
callback, ext-all-debug-w-comments.js, Línea 8911
onComplete, ext-all-debug-w-comments.js, Línea 27879
onStateChange, ext-all-debug-w-comments.js, Línea 27817
Anonymous function, ext-all-debug-w-comments.js, Línea 2401





Combobox's view not defined? Trying to set a value. EXTJS 4.0.7

Aucun commentaire:

Enregistrer un commentaire