1. #1
    Sencha User
    Join Date
    Jul 2013
    Posts
    7
    Vote Rating
    0
    wdieujus is on a distinguished road

      0  

    Default Unanswered: Combobox with store using ajax proxy json reader

    Unanswered: Combobox with store using ajax proxy json reader


    Im having issues loading a store into a combobox. Not sure if the Json is incorrectly formatted or my store. Please provide any feedback possible. Thanks!

    Heres my json:

    {"success":true,
    "markets": [
    {"display":"TEST","value":"TEST.xml"}]
    }

    heres my store:

    var markets = Ext.create('Ext.data.Store', {
    fields: [{name: 'display'}, {name: 'value'}],
    autoLoad: true,
    proxy: {
    type: 'ajax',
    url: 'app/scripts/getMarketList.php',
    reader: {
    type: 'json',
    root: 'markets'
    }
    }
    });

    And heres my combobox:
    dockedItems: [
    {
    xtype: 'toolbar',
    items: [{
    xtype: 'combobox',
    forceSelection: true,
    editable: false,
    fieldLabel: 'Choose Market,
    store: markets,
    displayField: 'display',
    valueField: 'value'
    }
    ]
    }],

  2. #2
    Sencha Premium Member aaugen's Avatar
    Join Date
    Oct 2010
    Location
    Mulhouse, France (68200)
    Posts
    48
    Answers
    12
    Vote Rating
    18
    aaugen will become famous soon enough aaugen will become famous soon enough

      0  

    Default


    Hi,

    Are you data populated in your store?
    Check in JavaScript console if you send the right request and receive appropriate response. You can also try to put data directly in your store:
    Code:
    var markets = Ext.create('Ext.data.Store', {
                 fields: [{name: 'display'}, {name: 'value'}],
                 autoLoad: true,
                 data: [
            {"display":"TEST1","value":"TEST1.xml"},
            {"display":"TEST2","value":"TEST2.xml"}
         ]
    });
    Hoping this helps you.



    Alexandre AUGEN - Computer Engineer
    JNESIS
    20c rue du Chemnitz
    68200 Mulhouse - France
    Tél: +33 3 89 36 60 39

  3. #3
    Sencha User
    Join Date
    Jul 2013
    Posts
    7
    Vote Rating
    0
    wdieujus is on a distinguished road

      0  

    Default


    I'd rather not write the data directly in the store as the data is dynamic..

    The php script, while also echo'ing the final json, also writes it to a file. I tried changing the url in the store to read the json instead and it worked. So the output json should be correct.

  4. #4
    Sencha Premium Member tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,684
    Answers
    130
    Vote Rating
    112
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    1) to check if your JSON is valid try: http://jsonlint.com/ (it is correct).

    2) to debug this, use google chrome -> developer tools, go to the network tab and check if your request got send and what comes back.

    3) if 2 is fine, log the store to the console and see what is inside
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

Thread Participants: 2

Tags for this Thread