Showing posts with label Error. Show all posts
Showing posts with label Error. Show all posts

Wednesday, December 7, 2011

Object # Object has no method 'read'

Object #<Object> has no method 'read'


This error occurs usually when ExtJS cannot find a Model class that you are trying to use in a different Model or in a store.

To avoid this error, make sure:
(a) you use fully-qualified Model names wherever you refer to them. E.g., "contacts.model.AddressModel" instead of just "AddressModel".
(b) you have placed the file having the code for the Model class in the app\model folder
(c) you have a "requires" config set up on the respective Model or store object.

Here's an example: ContactModel references AddressModel


 Ext.define(
'contacts.model.ContactModel', {
extend: 'Ext.data.Model',
requires : [
'contacts.model.AddressModel'
],
fields: [
{ name: 'id', type: 'integer' },
{ name: 'name', type: 'string' },
{ name: 'company', type: 'string' },
{ name: 'age', type: 'integer' },
{ name: 'addresses', type: 'array' },
],
hasMany: {model: 'contacts.model.AddressModel', 
                                               name: 'addresses', associationKey:'addresses'}
});

Here's another example: ContactStore uses ContactModel


Ext.define('contacts.store.ContactStore', {
    extend: 'Ext.data.Store',

    constructor: function(cfg) {
        var me = this;
        cfg = cfg || {};
        me.callParent([Ext.apply({
            autoLoad: true,
            storeId: 'ContactStore',
requires: ['contacts.model.ContactModel'],
model: 'contacts.model.ContactModel',
singleton : true,
            proxy: {
                type: 'ajax',
                url: 'http://localhost/contacts.json',
                reader: {
                    type: 'json',
                    root: 'data'
                }
            }
        }, cfg)]);
    }
});



Tuesday, November 15, 2011

Setting up ExtJS 4.0 on IIS 7

I downloaded ExtJS 4.0 (Commercial evaluation version) from http://www.sencha.com/products/extjs/download?page=a

1. Copied to c:\inetpub\wwwroot\ExtJS folder.
(Note: while extracting the zipped files, it would create a ExtJS\ext-js-4.0.7 folder, but i deleted the ext-js-4.0.7 folder after moving all its contents to its parent folder ExtJS. This is just for convenience)

2. Browsed to http://localhost/ExtJS and saw index.html getting rendered without issues. Woo hoo!

While trying to run a sample from (IntroToExt2) from http://www.sencha.com/learn/ext-js-essentials, I got the following error:
Invalid Character
ext-base.js
Line: 1
Code: 0
Char: 1


Not sure exactly why this error occurred. Googling for answers, I found this link: http://www.rahulsingla.com/blog/2011/04/extjs-4-running-docs-over-iis-in-windows. Following the instructions there, I added .json MIME type to IIS and that solved the issue!