Results 1 to 4 of 4

Thread: Combobox with store using ajax proxy json reader

  1. #1
    Sencha User
    Join Date
    Jul 2013
    Posts
    7
    Vote Rating
    0
      0  

    Default 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
    64
    Answers
    14
    Vote Rating
    18
      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
    40 rue Victor Schoelcher
    68200 Mulhouse - France

    Tl: +33 3 89 36 60 39
    Fax: +33 3 89 32 76 31

  3. #3
    Sencha User
    Join Date
    Jul 2013
    Posts
    7
    Vote Rating
    0
      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 User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,748
    Answers
    130
    Vote Rating
    128
      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

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
  •