Results 1 to 3 of 3

Thread: DataView: Uncaught TypeError: Cannot read property 'items' of undefined

  1. #1
    Touch Premium Member msuresh's Avatar
    Join Date
    Dec 2007
    Location
    Bangalore, India
    Posts
    220

    Question DataView: Uncaught TypeError: Cannot read property 'items' of undefined

    Hi,

    I am getting the above error in Chrome and could not understand what is creating this problem. Can any one point me where I am doing a mistake.

    PHP Code:
    Ext.regStore("searchstr", {
        
    model"arsparams"
    });

    var 
    sStr Ext.getStore("searchstr");
    //Dummy data to test
    sStr.loadData({'m_iWarn':0,'m_iNotice':0,'m_id':-1,'m_iSize':50,'m_iOff':50,'hardwareWarrantyCount':50,'threats':0,'eosThreats':0,'pvtThreats':0});

    var 
    srchTmplt = new Ext.XTemplate(
    '<tpl for=".">',
    "<table id='search-list' cellpadding=0 cellspacing=0 border=0>",
    "<tr><td class='arslabel'>m_iWarn : </td><td class='arsvalue'>{m_iWarn}</td></tr>",
    "<tr><td class='arslabel'>m_iNotice : </td><td class='arsvalue'>{m_iNotice}</td></tr>",
    "<tr><td class='arslabel'>m_id : </td><td class='arsvalue'>{m_id}</td></tr>",
    "<tr><td class='arslabel'>m_iSize : </td><td class='arsvalue'>{m_iSize}</td></tr>",
    "<tr><td class='arslabel'>m_iOff : </td><td class='arsvalue'>{m_iOff}</td></tr>",
    "<tr><td class='arslabel'>hardwareWarrantyCount : </td><td class='arsvalue'>{hardwareWarrantyCount}</td></tr>",
    "<tr><td class='arslabel'>threats : </td><td class='arsvalue'>{threats}</td></tr>",
    "<tr><td class='arslabel'>eosThreats : </td><td class='arsvalue'>{eosThreats}</td></tr>",
    "<tr><td class='arslabel'>pvtThreats : </td><td class='arsvalue'>{pvtThreats}</td></tr>",
    "</table>",
    '</tpl>'
    );

    console.log(Ext.getStore("searchstr")); //Prints data

    app.views.SearchResults Ext.extend(Ext.DataView, {
        
    tplsrchTmplt,
        
    emptyText'No results found',
        
    itemSelector'arslabel',
        
    initComponent: function() {
            
    this.store Ext.getStore("searchstr");
            
    app.views.SearchResults.superclass.initComponent.apply(thisarguments);
        }
    });

    Ext.reg('searchresults'app.views.SearchResults); 
    Thanks,
    Suresh M R

  2. #2
    Touch Premium Member msuresh's Avatar
    Join Date
    Dec 2007
    Location
    Bangalore, India
    Posts
    220

    Default

    I need to pass the JSON data as an array. I modified the data like this and it solved my problem.

    PHP Code:
    sStr.loadData([{'m_iWarn':0,'m_iNotice':0,'m_id':-1,'m_iSize':50,'m_iOff':50,'hardwareWarrantyCount':50,'threats':0,'eosThreats':0,'pvtThreats':0}]); 

  3. #3

    Default

    Alternative Loading Methods:

    One of the methods I've done to try to simplify the logic inside of each component / view is to modify all of my models with debug logic.

    Inside of my Ext.regApplication I define a "debugMode":true flag which I can check globally doing
    APPNAME.debugMode === true

    Once I have that I modify my model's such that the "proxy" config can equal one of two things:

    If in debug mode a memoryproxy is defined and the data is either set inline using the "data" config, or I override the "read" method of the proxy to perform some dynamic mock data insertion (like if you want to be able to mockup going to the same screen with different values).

    The other scenario is the standard live version in which you define a standard proxy config with the url to your data.


    I've begun to like this setup as it moves the testing logic out of the components and into the models which are the ones loading the data anyways. It also allows for you to have dynamic logic setup so that your app can be run as realistically as possible while in debugMode.

    This also has the extra side benefit of using the standard Store.load() calls / events to populate and load data onto the page. Calling loadData skips a lot of the events and data massaging that a store would normally provide you. All of these leads up to having to setup inline calls to loadData and to your after data load events while in my method the components treat the stores just like how they would in a live setup and have no idea that the data they're getting is mocked up.

    Hope this helps,


    Jordan



    Quote Originally Posted by msuresh View Post
    Hi,

    I am getting the above error in Chrome and could not understand what is creating this problem. Can any one point me where I am doing a mistake.

    PHP Code:
    Ext.regStore("searchstr", {
        
    model"arsparams"
    });

    var 
    sStr Ext.getStore("searchstr");
    //Dummy data to test
    sStr.loadData({'m_iWarn':0,'m_iNotice':0,'m_id':-1,'m_iSize':50,'m_iOff':50,'hardwareWarrantyCount':50,'threats':0,'eosThreats':0,'pvtThreats':0});

    var 
    srchTmplt = new Ext.XTemplate(
    '<tpl for=".">',
    "<table id='search-list' cellpadding=0 cellspacing=0 border=0>",
    "<tr><td class='arslabel'>m_iWarn : </td><td class='arsvalue'>{m_iWarn}</td></tr>",
    "<tr><td class='arslabel'>m_iNotice : </td><td class='arsvalue'>{m_iNotice}</td></tr>",
    "<tr><td class='arslabel'>m_id : </td><td class='arsvalue'>{m_id}</td></tr>",
    "<tr><td class='arslabel'>m_iSize : </td><td class='arsvalue'>{m_iSize}</td></tr>",
    "<tr><td class='arslabel'>m_iOff : </td><td class='arsvalue'>{m_iOff}</td></tr>",
    "<tr><td class='arslabel'>hardwareWarrantyCount : </td><td class='arsvalue'>{hardwareWarrantyCount}</td></tr>",
    "<tr><td class='arslabel'>threats : </td><td class='arsvalue'>{threats}</td></tr>",
    "<tr><td class='arslabel'>eosThreats : </td><td class='arsvalue'>{eosThreats}</td></tr>",
    "<tr><td class='arslabel'>pvtThreats : </td><td class='arsvalue'>{pvtThreats}</td></tr>",
    "</table>",
    '</tpl>'
    );

    console.log(Ext.getStore("searchstr")); //Prints data

    app.views.SearchResults Ext.extend(Ext.DataView, {
        
    tplsrchTmplt,
        
    emptyText'No results found',
        
    itemSelector'arslabel',
        
    initComponent: function() {
            
    this.store Ext.getStore("searchstr");
            
    app.views.SearchResults.superclass.initComponent.apply(thisarguments);
        }
    });

    Ext.reg('searchresults'app.views.SearchResults); 
    Thanks,
    Suresh M R

Posting Permissions

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