Results 1 to 4 of 4

Thread: Record.creaye() ?show" Uncaught TypeError: Cannot read property 'items' of undefine "

  1. #1
    Sencha User
    Join Date
    Apr 2014
    Posts
    44
    Answers
    1

    Default Record.creaye() ?show" Uncaught TypeError: Cannot read property 'items' of undefine "

    Dear ?
    I try to read Array to store.
    I use a sample as fellow?But it show
    Uncaught TypeError: Cannot read property 'items' of undefined
    in console.

    I check it, and find it's woring in " var Customer = Ext.data.Record.create(["
    but, I don;t know why?
    somebody can help me?
    thx.

    Code:
            Ext.onReady(function(){
                var customers = [
                    [1, "David Wang", 27, "Programmer", "1983-01-01"],
                    [2, "Mary Chen", 25, "Sales", "1985-11-22"],
                    [3, "Christina Zung", 22, "Accountant", "1988-03-28"],
                    [4, "Joe Fun", 30, "Lawyer", "1980-05-10"]
                ];
    
                
                var Customer = Ext.data.Record.create([
                    { name:'id',         type:'int',    mapping:0 },
                    { name:'name',       type:'string', mapping:1 },
                    { name:'age',        type:'int',    mapping:2 },
                    { name:'occupation', type:'string', mapping:3 },
                    { name:'dob',        type:'string', mapping:4, dataFormat:'Y-m-d' }
                ]);
    
                var customerReader = new Ext.data.ArrayReader({idIndex:0},Customer);
    
                /* non-proxy way
                var customerStore = new Ext.data.Store({
                    reader:customerReader
                });
                customerStore.loadData(customers);
                */
    
                // proxy way
                var customerProxy = new Ext.data.MemoryProxy(customers);
                var customerStore = new Ext.data.Store({
                    proxy:customerProxy,
                    reader:customerReader
                });
                customerStore.load();
    
                console.debug(customerStore.getAt(1).get('name'));
            });

  2. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    In which version of ExtJS are you running this?

  3. #3
    Sencha User
    Join Date
    Apr 2014
    Posts
    44
    Answers
    1

    Default

    Dear? I running it in the Extjs 4.2.

  4. #4
    Sencha User
    Join Date
    Apr 2014
    Posts
    44
    Answers
    1

    Default

    Dear?
    I had chaged the Customer as Array object?the it pass.
    but?there are 2 Question ?

    Q1.non-proxy:
    if i use non-proxy way ,it show "cannot read property 'getProxy' of undefined"
    why? how to solve it?

    Q2.proxy way?
    when I use console.debug(customerStore.getCount());
    it show 0. why? the data of customers doesn't been loaded.

    And? console.debug(customerStore.getAt(1).get('name'));
    it show "Uncaught TypeError: Cannot read property 'get' of undefined " ?

    help!!!

    Code:
            
                var customers = [
                    [1, "David Wang", 27, "Programmer", "1983-01-01"],
                    [2, "Mary Chen", 25, "Sales", "1985-11-22"],
                    [3, "Christina Zung", 22, "Accountant", "1988-03-28"],
                    [4, "Joe Fun", 30, "Lawyer", "1980-05-10"]
                ];
                
            //-------->CHAGE TO THIS -->OK PASS    
                var Customer = Ext.data.Record.create(
                    { name:'id',         type:'int',    mapping:0 },
                    { name:'name',       type:'string', mapping:1 },
                    { name:'age',        type:'int',    mapping:2 },
                    { name:'occupation', type:'string', mapping:3 },
                    { name:'dob',        type:'string', mapping:4, dataFormat:'Y-m-d' }
                );
    
    
                var customerReader = new Ext.data.ArrayReader({idIndex:0},Customer);
    
                // non-proxy way-----------Q1.
                var customerStore =Ext.create('Ext.data.Store',   {reader:customerReader}
                );
                
                customerStore.loadData(customers);
                console.debug(customerStore.getAt(1).get('name'));  
     
                
                // proxy way----------Q2.
                
                     var customerProxy = new Ext.data.MemoryProxy(customers);
                var customerStore = new Ext.data.Store({
                    proxy:customerProxy,
                    reader:customerReader
                });
                customerStore.load();
    
               // console.debug(customerStore.getAt(1).get('name'));
                console.debug(customerStore.getCount());

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •