PDA

View Full Version : Detect errors in JsonReader with ScripTagProxy



sunco
20 Feb 2010, 9:59 AM
Reading the docs i see that you can detect if the data is valid with isData

I check it but can't make it works. Hope somebody can help on this

On previous code this works fine but now i want to detect when the values are not valid Json stuff.



var lala = new Ext.data.JsonReader({
root: 'calles',
totalProperty: 'registros',
id: 'id_calle',
fields: [
{name: 'nom_calle'},
{name: 'nom_colonia'},
{name: 'nom_ciudad'},
{name: 'nom_estado'}
]
});

var storeAjax = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: 'includes/ajax.php?accion=BuscaCalle',
listeners: {
'exception': function(dataProxy, type, action, options, response, arg) {
alert("error");
},
'load': function(dataProxy, o, options) {
// this return false all time
alert(lala.isData(o));
}
}
}),
reader: lala
});


When the Json values are not valid it causes an error on this line (from ext-all-debug.js)



onTypeAhead : function(){
if(this.store.getCount() > 0){
var r = this.store.getAt(0);
var newValue = r.data[this.displayField];
var len = newValue.length;
var selStart = this.getRawValue().length;
if(selStart != len){
this.setRawValue(newValue);
this.selectText(selStart, newValue.length);
}
}
},

sunco
22 Feb 2010, 8:28 AM
Anybody ? How to detect invalid JSON values ?

Don't want to modify ext-all-debug.js

Or maybe a way to extend/override the ext-all-debug.js onTypeAhead function