Results 1 to 3 of 3

Thread: Problem accessing store and loading data into store

  1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default Problem accessing store and loading data into store

    Hi guys, i'm new to Sencha, and right now, im having some issues with the store system. I created a list view to get data from a store, the store is connected to a model and uses ajax as source to get the required data from mysql database (a search system/engine). my code is as follows;

    Model:
    Ext.define('MyApp.model.MyModel', {
    extend: 'Ext.data.Model',

    config: {
    fields: ['field1', 'field2', 'field3', 'field4', 'field5', 'field6', 'field7', 'field8']
    },
    });

    Store:
    var stor=Ext.define('MyApp.store.MyStore', {
    extend: 'Ext.data.Store',
    requires: 'MyApp.model.MyStore',

    config: {
    autoLoad: true,
    //storeId: 'myId', Problem 1
    model: 'MyApp.model.SearchResult',
    proxy: {
    method: 'GET',
    type: 'ajax',
    url: 'handler.php',
    extraParams: {
    get_items: 'yes',
    },
    reader: {
    type: 'xml',
    root: 'records',
    record: 'record',
    }
    }
    }
    });

    List View:
    Ext.define('MyApp.view.MyList', {
    extend: 'Ext.List',
    xtype: 'listresult',
    requires: ['MyApp.store.MyStore'],

    config: {
    title: 'Store',
    itemTpl: '{field1}',
    store: 'MyStore',
    onItemDisclosure: true,
    }
    });

    Without giving the store a "storeId", the store connects with the handler.php and gets the default list. I then try to change the list when users enter something in the search form, the form is submitted to change the what data will be returned when the list page loads (list page is called when the search form is submitted), instead, it loaded the default list.
    I thought about using the setData() or/and setProxy() methods, but they require an object of the store, so I added the storeId config then assigned the store object to a variable "my", ie

    var "myliststore"=Ext.getStore("myliststore");

    On doing this, i created the object, but now, the list is supplied no data from the store. I then tried to supply data using
    myliststore.setProxy({
    method: 'GET',
    type: 'ajax',
    url: 'handler.php',
    extraParams: {
    get_items: 'yes',
    },
    reader: {
    type: 'xml',
    root: 'records',
    record: 'record',
    }
    });
    No data was loaded still. Please, I'll like for anyone to help me, I've been on this for 2 days now

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3932
    Vote Rating
    1272
      0  

    Default

    So all you need to do now is load the store? store.load() ?
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default thanks Mitch

    i figured that out

Tags for this Thread

Posting Permissions

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