PDA

View Full Version : Method "store.load()" error in IE 7



anpegar
15 Oct 2010, 4:16 AM
Hi,
I have a dataview with a panel that displays news when i press the button "Load News", but when I press this button IE7 javascript error occurs. In firefox with firebug work fine.
In line 1079 of ext-all-debug.js is the following code: results = [];

my Code:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="/productos_v2/css/apl_sopor/estilos.css" />

<link rel="stylesheet" type="text/css" href="/productos_v2/libs/ext-3.2.1/resources/css/ext-all-notheme.css" />
<link rel="stylesheet" type="text/css" href="/productos_v2/libs/ext-3.2.1/resources/css/xtheme-blue.css" />



<script type="text/javascript" src="/productos_v2/libs/ext-3.2.1/adapter/ext/ext-base.js" ></script>
<script type="text/javascript" src="/productos_v2/libs/ext-3.2.1/ext-all-debug.js" ></script>
<script type="text/javascript" src="/productos_v2/libs/ext-3.2.1/src/locale/ext-lang-es.js" ></script>

<!-- Inicio de la página -->
<script>

var ProxyNoticias = new Ext.data.HttpProxy({
id: 'ProxyNoticias',
url: '/sopordes/pk_dwu_servicio_datos_json.read?p_entidad=NOTICIAS&p_subentidad=PORTAL_CLIENTE&p_param=P_USR&p_value=profiltek&p_param=P_FORMATO&p_value=&p_param=P_TEXTO&p_value=',method: 'POST',
nocache: true
});


var ReaderNoticias = new Ext.data.JsonReader({
root: 'data',
totalProperty: 'totalCount',
successProperty: 'success',
messageProperty: 'message',
fields: [{name:'CODIGO', type:'int'},
{name:'IMPORTANTE', type:'string'},
{name:'WNO_FECHA', type:'date'},
{name:'WNO_TITULAR', type:'string'},
{name:'ANCLA', type:'string'},
{name:'ANCLA_DEMO', type:'string'},
{name:'ANCHO', type:'string'},
{name:'ALTO', type:'string'},
{name:'TEXTO_ANCLA_DEMO', type:'string'}]
});


var StoreNoticias = new Ext.data.Store({
id: 'StoreNoticias',
reader: ReaderNoticias,
proxy: ProxyNoticias
});


var TplNoticia = new Ext.XTemplate(

'<tpl for=".">',
'<div>{WNO_TITULAR}</div>',
'</tpl>'

);



Ext.onReady(function(){
Ext.BLANK_IMAGE_URL = '/productos_v2/libs/ext-3.2.1/resources/images/default/s.gif';
Ext.Ajax.disableCaching = false;
Ext.QuickTips.init();




var Noticias = new Ext.DataView({
id: 'Noticias',
store: StoreNoticias,
tpl: TplNoticia,
autoHeight: true,
overClass: 'x-view-over',
emptyText: 'No existen datos.'
});


var zonaDerechaSup = new Ext.Panel({
id: 'zonaDerechaSup',
title: 'News',
layout: 'auto',
autoScroll: true,
border: true,
items: [Noticias],
renderTo: Ext.getBody(),
width: 500,
height: 400,
bbar: ['->',new Ext.Button({
text: 'Load News',
handler: function (){StoreNoticias.load();}
})]
});


}); //end onReady
</script>

</head>
<body>
</body></html>


Thanks in advanced.

2285522854

Animal
15 Oct 2010, 4:30 AM
How are you generating the JSON? If you are making it up yourself, then I suspect a trailing comma.

You should be using a JSON library.

anpegar
15 Oct 2010, 4:33 AM
This is my JSON generated from my BBDD:
is ok?



{"success":true,"message":"Datos Cargados","totalCount":"3","data":[{ "CODIGO" : 25, "IMPORTANTE" : "S", "WNO_FECHA" : "02-AUG-10", "WNO_TITULAR" : "Nuevos Tipos Impositivos IVA", "ANCLA" : "\/expertweb\/01 soporte \/imagenes\/f480761227\/documento sobre cambio de iva.pdf", "ANCLA_DEMO" : "http:\/\/www.d.es", "ANCHO" : 600, "ALTO" : 500, "TEXTO_ANCLA_DEMO" : "[ valor ]" },{ "CODIGO" : 29, "IMPORTANTE" : "S", "WNO_FECHA" : "02-AUG-10", "WNO_TITULAR" : "Nueva Ley de lucha contra la Morosidad", "ANCLA" : '', "ANCLA_DEMO" : "http:\/\/www.d.es", "ANCHO" : 600, "ALTO" : 500, "TEXTO_ANCLA_DEMO" : "[ valor ]" },{ "CODIGO" : 28, "IMPORTANTE" : "S", "WNO_FECHA" : "02-AUG-10", "WNO_TITULAR" : "Recalculo de Cuotas de Leasing", "ANCLA" : "\/expertweb\/01 valord\/imagenes\/f286913978\/documento sobre cambio de iva revisado 10_06.pdf", "ANCLA_DEMO" : "http:\/\/www.d.es", "ANCHO" : 600, "ALTO" : 500, "TEXTO_ANCLA_DEMO" : "[ valor ]" }]}

Animal
15 Oct 2010, 4:44 AM
Making it readable:



{
"success": true,
"message": "Datos Cargados",
"totalCount": "3",
"data": [{
"CODIGO": 25,
"IMPORTANTE": "S",
"WNO_FECHA": "02-AUG-10",
"WNO_TITULAR": "Nuevos Tipos Impositivos IVA",
"ANCLA": "\/expertweb\/01 soporte \/imagenes\/f480761227\/documento sobre cambio de iva.pdf",
"ANCLA_DEMO": "http:\/\/www.d.es",
"ANCHO": 600,
"ALTO": 500,
"TEXTO_ANCLA_DEMO": "[ valor ]"
}, {
"CODIGO": 29,
"IMPORTANTE": "S",
"WNO_FECHA": "02-AUG-10",
"WNO_TITULAR": "Nueva Ley de lucha contra la Morosidad",
"ANCLA": '',
"ANCLA_DEMO": "http:\/\/www.d.es",
"ANCHO": 600,
"ALTO": 500,
"TEXTO_ANCLA_DEMO": "[ valor ]"
}, {
"CODIGO": 28,
"IMPORTANTE": "S",
"WNO_FECHA": "02-AUG-10",
"WNO_TITULAR": "Recalculo de Cuotas de Leasing",
"ANCLA": "\/expertweb\/01 valord\/imagenes\/f286913978\/documento sobre cambio de iva revisado 10_06.pdf",
"ANCLA_DEMO": "http:\/\/www.d.es",
"ANCHO": 600,
"ALTO": 500,
"TEXTO_ANCLA_DEMO": "[ valor ]"
}]
}

looks OK.

I can only suggest trying this on IE8 where there is a debugger, and debugging it.

jracine
15 Oct 2010, 6:20 AM
I have exactly the same problem in IE7, but instead of using a JsonStore, I used an ArrayStore.
So I don't think, the problem is a trailing comma.
I'm using version 3.3.0 of ExtJS.
Here's a part of my code:


var showMyPrograms = function( programs ) {
var progStore = new Ext.data.ArrayStore({
fields: [
{name: 'pid'},
{name: 'program'}
],
idIndex: 0
});
progStore.loadData(programs);

var tplProg = new Ext.XTemplate(
'<tpl for=".">',
'<div>{program}</div>',
'</tpl>'
);

var listPrograms = new Ext.DataView({
id: 'programs-view',
store: progStore,
tpl: tplProg,
autoHeight:true
});

Ext.getCmp('prog-panel').add(listPrograms);
Ext.getCmp('prog-panel').doLayout();
};
The array that I received in parameters is:
[["6", "Enseignement au préscolaire et au primaire"], ["5", "Psychoéducation"]]

I will continue to try to debug it, but if someone have solution or hints before, it would be appreciated.
Thanks.

jracine
15 Oct 2010, 7:11 AM
I finally resolved the problem.
The problem was not from the store, but in the configuration of the dataView.
We have to specify an itemSelector as it mentionned in the API of the DataView.
Here's a link to a post that gave me the solution: http://www.sencha.com/forum/showthread.php?52528-DataView-SimpleStore-Path-us-undefined.
So my DataView is now defined like this:


var listPrograms = new Ext.DataView({
id: 'programs-view',
store: progStore,
tpl: tplProg,
itemSelector : 'div',
autoHeight:true
});

anpegar
17 Oct 2010, 10:27 PM
Ok jracine, works fine !!
Thank you very much to all.