Results 1 to 5 of 5

Thread: displaying Nested Model in two different combobox

  1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    3
    Vote Rating
    0
      0  

    Default displaying Nested Model in two different combobox

    I have one store that generate nested data I want to call server only once to load this data

    {"data":[{"firstCombo":"A","data1":[{"seccondCombo":"B,C"}],"data2":[{"thirrdCombo":"D,E"}]}]}

    so what should be the model and view code so that I can populate three comboboxes without calling server again and again I am able to populate first combobox using a store that have root : data

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505
    Vote Rating
    255
      0  

    Default

    Are you using an Ext.Ajax.request() to pull the data down?
    If so, once you have the data you can Ext.decode() the response. Then in a callback you can do something like:

    Code:
    combo1.getStore().loadData(resp.data.firstCombo);
    combo2.getStore().loadData(resp.data.data1.secondCombo);
    ... etc.

  3. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    3
    Vote Rating
    0
      0  

    Default

    Thanks for your reply ,
    yes I am using Ajax request , but I am using extjs 4 I have a Store
    proxy: {
    type: 'ajax',
    url: abc.do',
    reader: {
    type: 'json',
    root: 'data'
    }
    }

    and define model with hasMany relation of different model.

    and below is my view that uses store

    {
    xtype: 'combobox',
    fieldLabel: 'Name',
    store: 'myStore,
    displayField: 'firstCombo',
    valueField: 'firstCombo'
    },



    {
    xtype: 'combobox',
    fieldLabel: 'Type',
    store: ,
    displayField: ,
    valueField: '
    },
    here I am able to display data in first combo
    so please let me know what should I give in the second combo in store, displaytype and value filed to display data



    Quote Originally Posted by slemmon View Post
    Are you using an Ext.Ajax.request() to pull the data down?
    If so, once you have the data you can Ext.decode() the response. Then in a callback you can do something like:

    Code:
    combo1.getStore().loadData(resp.data.firstCombo);
    combo2.getStore().loadData(resp.data.data1.secondCombo);
    ... etc.

  4. #4
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505
    Vote Rating
    255
      0  

    Default

    You mentioned using a hasMany - does each record for ComboA have a series of records you'll be loading to ComboB when a record is selected in ComboA or the list for ComboB is static - not dependent on a selection from ComboA?

  5. #5
    Sencha User
    Join Date
    Apr 2013
    Posts
    3
    Vote Rating
    0
      0  

    Default

    Yes, they are dependent on ComboA, mean for single Value of ComboA there would be a list of values for Combp B & C

Posting Permissions

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