1. #1
    Sencha User
    Join Date
    May 2010
    Posts
    68
    Answers
    2
    Vote Rating
    1
    ZyBeR is on a distinguished road

      0  

    Default Answered: Why is my list not loading data?

    Answered: Why is my list not loading data?


    Could anyone help me out, I just begun using Sencha Touch so this it my first app attempt.

    I want to setup a global data store, populate it with a Json array from a variable so the store type should be memory. The bind the store to a list and push the list into view.

    I can create and populate the store, the list panel pushes into view but is empty.
    I'm pretty sure it's a simple mistake but I can not figure it out, been trying for the last three hours..

    Store
    PHP Code:
    Ext.define('Lanetalk.store.Customers', {
       
    extend'Ext.data.Store',
       
    config: {
            
    model'Lanetalk.model.Customer',
            
    proxy: {
                
    type'memory',
                
    reader: {
                    
    type'json'
                
    }
            },
            
    autoLoadtrue
    }}); 
    Model
    PHP Code:
    Ext.define('Lanetalk.model.Customer', {
        
    extend'Ext.data.Model',
            
    config: {
            
    fields: [
                {
    name'uuid'type'string'},
                {
    name'premium'type'string'},
                {
    name'location'type'string'},
                {
    name'address'type'string'},
                {
    name'longitude'type'string'},
                {
    name'latitude'type'string'},
                {
    name'company_name'type'string'},
                {
    name'official_phone'type'string'},
                {
    name'url'type'string'},
                {
    name'system'type'string'},
                {
    name'lanes'type'string'},
                {
    name'visitors_current'type'string'},
                {
    name'active_games'type'string'},
                {
    name'active_uploads'type'string'},
                {
    name'active'type'string'}
            ]
    }}); 
    List
    PHP Code:
    Ext.define('Lanetalk.view.Customers', {
        
    extend'Ext.form.Panel',
        
    xtype'customers',

        
    requires: [
            
    'Ext.dataview.List',
            
    'Ext.data.Store',
            
    'Lanetalk.store.Customers'
        
    ],

        
    config: {
            
    items: {
                
    xtype'list',
                
    itemTpl'{company_name}',

                
    store'Customers'
            
    }
    }}); 
    Method that populates the store and creates the list
    PHP Code:
    var customersStore Ext.getStore('Customers');
    console.log('Items in Store: 'customersStore.getCount());
    customersStore.removeAll();

    Ext.Array.each(record.get('customers'), function(customerindex) {
        
    customersStore.add(customer);
    });
    customersStore.sync();

    this.getCountries().push({
        
    xtype'customers'
    }); 

  2. It turned out that the store was working, but the list was not showing the items due to it was inside a panel. When I removed the panel the list worked with no other modifications.

    How ever, your suggestions are interesting.

    When I create a store and populate it manually (from a local variable), shall I not set any proxy? If so, when is the memory type used?

    The record variable is a subset of a json object.

  3. #2
    Sencha User
    Join Date
    Oct 2012
    Posts
    17
    Answers
    1
    Vote Rating
    0
    transwebsolutions is on a distinguished road

      0  

    Default


    The data you have listed on model as such.

    {name: 'uuid', type: 'string'},
    {
    name: 'premium', type: 'string'},
    {
    name: 'location', type: 'string'},
    {
    name: 'address', type: 'string'},
    {
    name: 'longitude', type: 'string'},
    {
    name: 'latitude', type: 'string'},
    {
    name: 'company_name', type: 'string'},
    {
    name: 'official_phone', type: 'string'},
    {
    name: 'url', type: 'string'},
    {
    name: 'system', type: 'string'},
    {
    name: 'lanes', type: 'string'},
    {
    name: 'visitors_current', type: 'string'},
    {
    name: 'active_games', type: 'string'},
    {
    name: 'active_uploads', type: 'string'},
    {
    name: 'active', type: 'string'}


    this needs to be on the store not model. Your model should only contain {name} and {type}.

    Also you don't need proxy in your store. The data is already there. Proxy is only used to retrieve data from another server.

    Hope that helps

  4. #3
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Answers
    64
    Vote Rating
    20
    haduki will become famous soon enough haduki will become famous soon enough

      0  

    Default


    Code:
    Ext.Array.each(record.get('customers'), function(customer, index) {
        customersStore.add(customer);
    });
    what is 'record'? Are you sure the type of 'customers' field is 'auto'?
    I write English by translator.

  5. #4
    Sencha User
    Join Date
    May 2010
    Posts
    68
    Answers
    2
    Vote Rating
    1
    ZyBeR is on a distinguished road

      0  

    Default


    It turned out that the store was working, but the list was not showing the items due to it was inside a panel. When I removed the panel the list worked with no other modifications.

    How ever, your suggestions are interesting.

    When I create a store and populate it manually (from a local variable), shall I not set any proxy? If so, when is the memory type used?

    The record variable is a subset of a json object.

Thread Participants: 2