1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Vote Rating
    0
    titombo is on a distinguished road

      0  

    Default Unanswered: Error: reader.read is not a function

    Unanswered: Error: reader.read is not a function


    Hi everybody,

    I would like to know what to do in the situation where I have the model:

    Code:
    
    //MODEL 
    Ext.define('StockAddressGrid.model.StockAddress', 
    {   
      extend: 'Ext.data.Model'    
     , fields: ['Id', 'AddressName', 'Description', 'AddressType', 'IsActive']    
     , proxy: {         
      type: 'ajax' ,
      api: {   
              read: '/StockAddress/StockAddress/StockAddressList'
              , extraParams:   { total: 50000}         
              , reader: 
              {        
                             type: 'json'             
                            , root: 'StockAddresses'          
                            , successProperty: 'success'           
                            , totalProperty: 'total'        
               }         
               ,
               simpleSortMode: true     
    } 
    });
    The store:
    Code:
    //STORE 
    /// <reference path="ext-4.0/ext-all.js" /> 
    Ext.define(
    'ReceiveInventoryPart.store.ReceiveInventoryParts'
    ,{     
           extend: 'Ext.data.Store'     
           , model: 'StockAddressGrid.model.StockAddress'     
           , proxy:
          {         
               type: 'ajax'         
               ,api:         
              {             
                     read: '/StockAddress/StockAddress/ActiveStockAddressList'        
               },    
               extraParams:      
              {
                       total: 50000
               }    
              , reader:        
             {
                     type: 'json'            
                     , root: 'ReceiveInventoryParts'           
                     , successProperty: 'success'         
                     , totalProperty: 'total'         
              }        
              , simpleSortMode: true     
              }   
              , autoLoad: true   
              , pageSize: 200    
              , remoteSort: true    
              , remoteFilter: true    
              , buffered: true   
              , sorters: ['AddressName']   
      });

    and the application:

    Code:
    /// <reference path="ext-4.0/ext-all.js" />  
     Ext.Loader.setConfig({ enabled: true }); 
    
    Ext.application(
    {   
      name: 'ReceiveInventoryPart', 
      appFolder: '../../Ext.js/app', 
      models: ['StockAddress'], 
      stores: ['ReceiveInventoryParts'],   
      launch: function ()      
        {       
               var receiveInventoryPartStore = this.getReceiveInventoryPartsStore();  
    
               Ext.create('Ext.form.ComboBox',         
              {             
                         id: 'cmbStockAddrress',      
                         name: 'cmbStockAddrress',         
                         store: receiveInventoryPartStore,       
                         queryMode: 'remote',             
                         renderTo: 'stockAddressExt',         
                         valueField: 'AddressName'       
               });    
        }
    });
    The data that is coming from the server has the JSON format:

    {"ReceiveInventoryParts":[{"Id":1,"AddressName":"aadd"},{"Id":2,"AddressName":"casas"},{"Id":3,"AddressName":"ccc"}]}

    The combobox is rendered, but I can't get the items, so I get the exception:

    reader.read is not a function
    result = reader.read(me.extractResponseData(response));


    Please, I would like to know what I am doing wrong?
    And can I use this structure, without Controller and using a Model for different Stores?

    Thanks,
    Tito
    Last edited by titombo; 15 Sep 2011 at 5:20 AM. Reason: format the code

  2. #2
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Answers
    26
    Vote Rating
    14
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    Well, I recommend to format your code with proper line intends. Hint: that might also point you to a problem in your model's proxy config.

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Vote Rating
    0
    titombo is on a distinguished road

      0  

    Default


    Quote Originally Posted by mberrie View Post
    Well, I recommend to format your code with proper line intends. Hint: that might also point you to a problem in your model's proxy config.
    I am overriding it's behavior defining the proxy on the store.
    Because this model is used by another stores.

  4. #4
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Answers
    26
    Vote Rating
    14
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    I can see that you override the proxy on your store.

    The error 'reader.read is not a function' tells me that something is wrong with your reader config. Clearly the 'reader' object is there, but doesn't have a 'read' method. So something is wrong here.

    I can see 2 problems:
    1. The proxy config in 'StockAddressGrid.model.StockAddress' is invalid. If you format the code properly you should be able to spot it - not sure if you have problems with the forum software or this is how you format your code.
    2. In 'StockAddressGrid.model.StockAddress' you define the API and its read method. Maybe this causes some havoc. You could just use the url property and see if this changes anything.
    3. If you use 4.0.2a I've read that there are some issues with proxies. E.g. see here.

  5. #5
    Sencha User
    Join Date
    Feb 2011
    Posts
    4
    Vote Rating
    0
    nitsko is on a distinguished road

      0  

    Default


    I have been struggling with the same problem since yesterday. Looks lke Ext doesn't recognize the model.

  6. #6
    Sencha User mberrie's Avatar
    Join Date
    Feb 2011
    Location
    Bangkok, Thailand
    Posts
    506
    Answers
    26
    Vote Rating
    14
    mberrie will become famous soon enough mberrie will become famous soon enough

      0  

    Default


    It might actually be a combination of (1) and (3). (3) might cause the proxy from the Model to kick in (due to a bug in 4.0.2a), and that will fail because of (1).

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi