1. #1
    Sencha User
    Join Date
    Sep 2010
    Posts
    16
    Vote Rating
    0
    uinewbie is on a distinguished road

      0  

    Default Dynamically created Combobox not working

    Dynamically created Combobox not working


    Hi,


    I'm using the the MVP architecture (with mvp4g) and need to dynamically create some widgets in the Presenter depending on the user selection of another widget. I was able to get textfield and checkbox working, but the combo box created does not respond to mouse clicks to expand the list (trigger field not responsive). I tried adding a listener to it, but it didn't seem to do anything. I'm not sure what I'm doing wrong. I'm still pretty new to GWT/GXT, so any help is greatly appreciated!


    Here's a the snippet of my code that creates the combobox:
    MyGXTComboBox list = new MyGXTComboBox("Test");
    list.setTriggerAction(TriggerAction.ALL);
    for(String value : myValues) {
    list.addItem(value);
    }
    list.setSelectedIndex(0);

    hp.add(list);
    list.render(hp.getElement());
    myWidgetMap.put("Test", list);



    Thanks!
    PN

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    list.render(hp.getElement());
    You should remove that line.

    What is "hp"? Where do you add it to?

  3. #3
    Sencha User
    Join Date
    Sep 2010
    Posts
    16
    Vote Rating
    0
    uinewbie is on a distinguished road

      0  

    Default


    oops, sorry that's a HorizonalPanel.
    If I remove it, the widget doesn't show up in my UI at all...

    The HorizonalPanel is added to a LayoutContainer that was pre-created in the View at bind time.

  4. #4
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Please post your code in a small, and standalone testcase. Normally you should never call render in your own.

  5. #5
    Sencha User
    Join Date
    Sep 2010
    Posts
    16
    Vote Rating
    0
    uinewbie is on a distinguished road

      0  

    Default


    Okay I just found that I can remove that render line, but the combo box is still not expanding.
    I still have to call render for the HorizontalPanel in order for the widgets to show up tho. Maybe I'm doing something wrong?

    Here's the code in the Presenter that's called inside a listener to another widget's click event:
    // Dynamically create the widgets
    List<MyBean> myList = curUserSelection.getListToCreate();
    LayoutContainer container = view.getMyPanel(); // This layout container was created in the View at bind time
    // clear the list of widgets first
    container.removeAll();
    myWidgetMap.clear();

    if(myList != null && myList.size() != 0) {
    for (MyBean bean : myList) {
    HorizontalPanel hp = new HorizonatlPanel(); // need to add some text after the combo box in the same row
    MyGXTComboBox list = new MyGXTComboBox(bean.getName());
    list.setTriggerAction(TriggerAction.ALL);
    for(String value : myValues) {
    list.addItem(value);
    }
    list.setSelectedIndex(0);
    hp.add(list);
    myWidgetMap.put(bean.getName(), list);
    Label label = new Label("some message");
    hp.add(label);
    container.add(hp);
    hp.render(container.getElement()); // if I remove this, the widget will not show...
    }
    container.setVisible(true);
    }

    Thank you very much for the help!!

  6. #6
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,966
    Vote Rating
    130
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Simple rendering something jsut creates the elements and you normally should not do that at all. I would remove all manual render calls in your app.

    after
    Code:
    container.add(hp);
    try to call
    Code:
    container.layout();

  7. #7
    Sencha User
    Join Date
    Sep 2010
    Posts
    16
    Vote Rating
    0
    uinewbie is on a distinguished road

      0  

    Default


    That worked!... Thank you so much!!

Similar Threads

  1. UpdateManager on dynamically created elements?
    By Slapyo in forum Ext 1.x: Help & Discussion
    Replies: 13
    Last Post: 13 Jan 2011, 3:25 PM
  2. Navigating between dynamically created Panels
    By bengundersen in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 17 Aug 2010, 10:34 AM
  3. Dynamically created checkboxes do not appear in the checkboxgroup
    By paweluz in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 25 Jun 2010, 1:48 AM
  4. How to resize a panel created dynamically ?
    By disizben in forum Ext 2.x: Help & Discussion
    Replies: 13
    Last Post: 7 Dec 2007, 7:45 AM

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar