PDA

View Full Version : Problem with Ext.data.Reader sample code



mozicodo
22 Oct 2010, 12:38 PM
I was having a problem with my Ext.data.Reader so I tried the sample code in the documentation but am getting the following error:

Uncaught TypeError: Cannot read property 'length' of undefined

mozicodo
22 Oct 2010, 8:56 PM
Ok. I have a little more information on this. I was working with a TreeStore and a NestedList and got the same error. I tried the NestedList page in the demo and it also got the same error.

The problem is when you have to read the file locally instead of from a webserver you get this error. I moved my code onto a webserver and it ran fine.

However, I still need to solve this problem as I'm planning on distributing this in a PhoneGap application and would prefer to not have to download the json data. However, I also don't want to load the json data until the user goes to that page in the web app. So I figure that there's two ways around this.

1) Dynamically load the javascript doing something like:


var fileref = document.createElement('script')
fileref.setAttribute('type', 'text/javascript)
fileref.setAttribute('src', 'data.js')


which might work but is ugly and kind of a hack.

2) Use some other way to call this I don't know about

3) It's a bug and needs to be fixed