[SOLVED] ComboBox JSON

January 6th, 2009
  • Hi,

    I'm trying to fetch data remotely from a python file to a comboBox, but i'm doing something wrong because its not working.

    Here is my code

    Ext.onReady(function(){
    Ext.QuickTips.init();

    // simple array store
    var store2 = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
    url: 'https://somelink.com/data.py?action=something',
    }),
    reader: new Ext.data.JsonReader({
    root: 'myData',
    fields: [{name: 'id'}, {name: 'vm'}]
    })
    });
    var combo = new Ext.form.ComboBox({
    store: store2,
    displayField:'vm',
    valueField: 'id',
    typeAhead: true,
    mode: 'remote',
    triggerAction: 'all',
    emptyText:'Select...',
    selectOnFocus:true,
    applyTo: 'someID'
    });


    The url https://somelink.com/data.py?action=something returns:

    {'myData': [{'id': '1', 'vm': 'field1'}, {'id': '2', 'vm': 'field2'}]}

    Can anyone help me on this?

    Thanks


  • SOLVED:

    Needed to add method: 'GET', by default it makes a POST.

    It should be like this

    proxy: new Ext.data.HttpProxy({
    method: 'GET',
    url: 'https://somelink.com/data.py?action=something',
    }),


  • It did not work. :(


  • try setting mode to local (mode: 'local' ). Don't know where i read that, can't find it right now, but that could help you.


  • I'm using firebug, and the XHR request is being done and the data is returned correctly. But i find something strange when debugging the script combo.js, RecordType appears in red and fields appears as [undefined, undefined] and prototypes is Object fields=[2] dirty=false editing=false.

    After step over...

    store: store2

    store returns undefined
    store2 returns Object data[0]

    Firebug doesn't report any specific error, the data just doesn't appear.


  • It looks good, what error specifically are you getting?
    tried debugging in firefox? make sure a request is being made, that the json is indeed returning correctly, and no errors are being thrown.


  • Its true if you use mode: 'local', but if you put mode: 'remote' i think you have to explicitly tell proxy to use get method.

    I'm saying this because i have done some tests and thats the way it works for me. If i use mode: 'remote' without method: 'GET' it doesn't work, but it works without method: 'GET' if i set mode to local.


  • That should not have made any difference, so you probably "fixed" something else in the process ;)
    Ext uses GET if there are no params, and POST if there are by default. And if that did make the difference, you werent getting back the correct json to begin with.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about [SOLVED] ComboBox JSON , Please add it free.