PDA

View Full Version : [SOLVED]TriggerField and "a is undefined"



jamesdesouza
24 Jun 2010, 5:24 AM
Hi,


var myEczList = new Ext.form.TriggerField({
id: 'ecz',
xtype: 'trigger',
name: 'query',
displayField: 'user_Ecz',
valueField: 'user_Ecz',
fieldLabel: 'Ezcane',
width: 250,
validateOnBlur: false,
triggerClass: 'x-form-search-trigger'
});
myEczList.onTriggerClick = function () {
if ((myEczList.getValue()).length >= 3) {
//--------------------------------------------------------
var bMsg = Ext.Msg.show({
title: 'Aran?yor...',
wait: true,
msg: 'Kullan?c?lar içerisinde aran?yor. Lütfen bekleyiniz.'
});
//--------------------------------------------------------
var filterStr = new Ext.data.JsonStore({
url: "../main/system_functions.aspx?_i=getEczGridSource&query=" + myEczList.getValue(),
autoLoad: true,
root: 'data',
totalCount: 'toplam',
remoteSort: true,
fields: ['user_ID', 'user_Ecz']
});
filterStr.on("load", function () {
bMsg.hide();
if (filterStr.totalLength > 0) {
var liste = '<table width="250" cellpadding="1" cellspacing="0">';
var renk = "";
for (w = 0; w <= filterStr.totalLength - 1; w++) {
renk = w % 2 == 0 ? "#ffffff" : "#f1f1f1";
var kayit = filterStr.getAt(w).json;
liste += '<tr bgcolor=' + Chr(34) + '' + renk + '' + Chr(34) + ' id=' + Chr(34) + 'urunSel_' + kayit.user_ID + '' + Chr(34) + ' onmouseover=' + Chr(34) + 'omOver(this,\'\')' + Chr(34) + ' onmouseout=' + Chr(34) + 'omOut(this,\'' + renk + '\')' + Chr(34) + ' style=' + Chr(34) + 'height:17px;background:' + renk + ';font-family:verdana;font-size:8pt;cursor:pointer;' + Chr(34) + ' onclick=' + Chr(34) + 'eczEkle(' + kayit.user_ID + ', \'' + kayit.user_Ecz + '\')' + Chr(34) + '><td align=' + Chr(34) + 'right' + Chr(34) + ' style=' + Chr(34) + 'background:none;width:35px;' + Chr(34) + '><strong>&nbsp;' + (w + 1) + ')&nbsp;</strong></td><td style=' + Chr(34) + 'background:none;' + Chr(34) + '>' + kayit.user_Ecz + '</td></tr>';
}
liste = liste + "</table>";
var urunHolderWindow = new Ext.Layer({
shadow: true,
id: 'myUrunPicker',
constrain: false,
cls: "triggerMenu colorTrigger",
zindex: 9999,
autoScroll: true
});
var uHWh = filterStr.totalLength * 20;
urunHolderWindow.alignTo('ecz', 'tl', [40, 40]);
urunHolderWindow.setHeight(uHWh > 180 ? 180 : uHWh);
urunHolderWindow.setWidth(265);
urunHolderWindow.show('ecz');
myEczList.on("focus", function () {
urunHolderWindow.hide();
urunHolderWindow.destroy();
});
urunHolderWindow.setStyle({
'overflow': 'auto'
});
urunHolderWindow.update(liste);
urunHolderWindow.on('click', function () {
urunHolderWindow.hide();
urunHolderWindow.destroy();
});
bMsg.hide();
}
else {
Ext.Msg.show({
title: 'Hata!',
msg: myEczList.getValue() + ' içeren kay?t bulunamad?'
});
}
});
}
else {
myEczList.markInvalid('Arama yapabilmek için lütfen en az 3 karakter giriniz');
}
}

TriggerField works great, but, when i click returned values in the layer(myEczList), i get the error "a is undefined".
i checked on firebug and found where the problem is.
...
}, validateValue: function (a) {
if (Ext.isFunction(this.validator)) {
var c = this.validator(a);
if (c !== true) {
this.markInvalid(c);
return false
}
}
if (a.length < 1 || a === this.emptyText) { //<<< problem is on this line
...

if i get the error, i can not use triggerfield anymore.
any idea? :-/

SOLUTION: there is a div ,on the document, has got same id with triggerfield :D
and sorry for my bad bad english:">

mankz
24 Jun 2010, 5:43 AM
When you debug ext js, make sure you're using the debug version. ext-all-debug.js which is a lot easier to debug than ext-all.js which is minified.