[CLOSED] Set Combo Box selected item on page load

  1. #1

    [CLOSED] Set Combo Box selected item on page load

    For my combo box

    X.ComboBoxFor(m => m.TYPE).ID("ComboBoxType").MultiSelect(false).LabelWidth(50).Width(150).Editable(false).Items(new ListItem("Invoice", "INV"), new ListItem("Pro-Forma", "PRO")).SelectedItems(X.ListItem().Value("INV")),
    I would like to select the first item on opening the window where the combo box is.

    Ext.onReady(function() {
                var combo = Ext.getCmp('ComboBoxType');
                combo.setValue('INV');
            });
    I keep getting

    Uncaught TypeError: Cannot read property 'setValue' of undefined
    What am I doing wrong please?
    Last edited by Daniil; Apr 03, 2015 at 12:08 PM. Reason: [CLOSED]
  2. #2
    Hi @registrator,

    A ComboBox is not rendered yet when the onReady handler is executed.

    Please clarify does SelectedItems not work for you? You should be able to set up a selected item's index as well.
    Last edited by Daniil; Mar 27, 2015 at 9:46 AM.
  3. #3
    Hi Daniil

    Select Index does not work for me. For some reason it is turning my combo into MultiSelect version that I cannot turn off.
    So I was thinking of setting the selected item when the page loads.
    If this is not a correct event, can you suggest some other event please?

    Thank you
  4. #4
    You can try with a ComboBox's AfterRender event.

    Though, I would really prefer to find out what is going wrong with SelectedItems. But I need a test case to reproduce.
  5. #5
    I would love to figure out why is the combo behaving like it is but I cannot reproduce this anywhere else but my solution.
    And I have spent so much time on it that I cannot afford to lose more. I just want to figure out a way to make it work no matter how dirty it is.
  6. #6
    I cannot reproduce this anywhere else but my solution
    Is there a possibility to share the test page online and publicly?

    I just want to figure out a way to make it work no matter how dirty it is.
    Does the AfterRender event help?
  7. #7
    I can actually deploy this on line to show you.
    Can I please send you the login credentials in a private message?
  8. #8
    I have managed to fix it with the AfterRender!!! Burden off my back.

    Thank you
  9. #9
    Can I please send you the login credentials in a private message?
    Sorry, we can deal with something that is accessible publicly. Never mind if you were able to sort out the problem.

Similar Threads

  1. Replies: 3
    Last Post: May 14, 2013, 4:03 AM
  2. Replies: 3
    Last Post: May 06, 2013, 6:44 AM
  3. Replies: 0
    Last Post: Apr 17, 2013, 7:41 AM
  4. Replies: 17
    Last Post: Dec 17, 2012, 11:58 AM
  5. [CLOSED] Load RadioGroup Item from database on Combo Select event
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 16, 2010, 8:30 PM

Posting Permissions