Results 1 to 5 of 5

Thread: Combobox not displaying values

  1. #1
    Sencha User
    Join Date
    Oct 2013
    Posts
    200
    Answers
    3

    Default Answered: Combobox not displaying values

    Hi,

    I have a combobox in which i have given configuration like-
    xtype : 'combobox',
    store : [],
    and some more configuration.

    I have a function where i want to populate the data in combobox.i am doing this by -
    combo.bindStore(records);
    where records are - {'001','002','003'}
    and this is working fine, i am able to see the data in combobox.
    now when i do the same code with data as - [] (basically an empty array)
    then its throwing some error then i tried by passing null like -
    combo.bindStore(null);
    then the store with the combobox unbinds, till this point it's fine , now again when i try to associate the combobox with some data it is giving me error as "store is null or undefined"

    I know as store is not associated anymore with the combobox so its giving error but i tried to replace the data by -
    combo.store.loadData(records, false);
    but again when i am trying to bind some data its giving some error in ext library.

    Can anyone please suggest how we can associate & remove data properly ina the same store ?

    Thanks,
    Ankit

  2. Avoid binding and unbinding stores unless you absolutely have to. You should definitely avoid binding null, a combobox needs to have a store at all times. If I were you I would just specify a suitable store when creating the combobox and then manipulate its contents, never calling bindStore.

    I'm not sure why loadData isn't working for you, without a working test case I can't easily investigate. You might want to try add and removeAll instead.

    A bit of a wild guess but the problems you're seeing may be something to do with the filtering the combobox performs on the store. You may want to dig in and remove the filter before changing the contents, see if that helps. You'll need to take a look at the combobox source code to better understand how that works.

    Failing that, have you attempted to debug the error you're seeing? Investigate the stacktrace, see if any obvious candidates emerge.

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    Is there any reason why you're changing the bound store rather than just changing the contents of the store? You can add or remove records from the store and the combobox should pick that up fine.

    Keep in mind that all these arrays are just converted to Ext.data.Store instances. If you can't get it to work with the array shorthand then pass full store configs instead, or even explicitly create the stores yourself.

  4. #3
    Sencha User
    Join Date
    Oct 2013
    Posts
    200
    Answers
    3

    Default

    AM
    Thanks skirtle for your reply,

    I just wanted to change the contents of the store but when i am doing bindStore first time it is working find and then i want to remove that records i tried that by -
    combo.store.loadData([],false);
    and then again when i want to add items to the combobox it didn't worked, I tried -

    combo.store.loadData(records,false) or
    combo.bindStore(records)

    But it's giving me some error,that "indexOf is null or defined"

    One more Question i want to ask - each time if i bind some records by bindStore and unbinds it by bindStore(null) it should work ? it is getting failed when i try to bind some store after i unbinded it.

    Thanks,
    Ankit


  5. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    Avoid binding and unbinding stores unless you absolutely have to. You should definitely avoid binding null, a combobox needs to have a store at all times. If I were you I would just specify a suitable store when creating the combobox and then manipulate its contents, never calling bindStore.

    I'm not sure why loadData isn't working for you, without a working test case I can't easily investigate. You might want to try add and removeAll instead.

    A bit of a wild guess but the problems you're seeing may be something to do with the filtering the combobox performs on the store. You may want to dig in and remove the filter before changing the contents, see if that helps. You'll need to take a look at the combobox source code to better understand how that works.

    Failing that, have you attempted to debug the error you're seeing? Investigate the stacktrace, see if any obvious candidates emerge.

  6. #5
    Sencha User
    Join Date
    Oct 2013
    Posts
    200
    Answers
    3

    Default

    PM
    Thanks for Prompt Reply Skirtle,

    The Problem got resolved by loadData function only, The problem was with data.I was taking array of string and binding it with combobox store.
    Then i put "[]" braces with each value in array and it works.

    But I really want to know how store works because i have not used filtering and all in that, Can you please suggest any link other than sencha docs that explains it with good examples ?

    Thanks,
    Ankit

Posting Permissions

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