1. #1
    Ext GWT Premium Member
    Join Date
    Jun 2010
    Location
    Kyrksæterøra, Norway
    Posts
    70
    Vote Rating
    2
    stigrv is on a distinguished road

      0  

    Default Unanswered: ComboBox with image support

    Unanswered: ComboBox with image support


    Is there an easy way to replace the input box in the combox widget with a simple element?

    For my combobox choices I use a label provider that builds a template with an image in front. If I try to use the same label provider for the combobox current value, I see the HTML tags of this template. This is caused by that the combobox widget uses an input box to view the current value.

    This makes sense if you want to allow text editing in the widget. I do however want the user to select from one of the provided alternatives. In this selection, the icon used in the list follows its text, and it would make sense to use the icon to visually represent the current value of the combobox.

    I've started to implement a custom cell implementation and an appearance, but I've run into problems related to the way the combobox widget is designed. The first problem is that it is not possible to pass in the appearance into the widget. I then tried to copy the code from the original combobox widget in order to make some changes to it, but run into problems with protected methods on the ViewData class.

  2. #2
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    39
    Vote Rating
    2
    hcr is on a distinguished road

      0  

    Default


    Did you come up with a solution for this?

    I also have the image in the dropdown and would like it to be displayed in the input element. Haven't started to look into the code but wanted to do some research first but your post doesn't raise my hopes.

    best regards,
    -hcr-

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    A new appearance can be passed into a ComboBoxCell constructor, and that cell used in building the ComboBox. There is no distinct appearance for the combo box, it just uses the TriggerFieldAppearance interface. I will look into adding constructor options in the ComboBox class itself, to avoid this extra set of steps.

    There must be a custom appearance, since there is no way to draw an icon inside an html <input type="text" > element, at least without drawing it over top of part of it or next to it (like the trigger icon itself).

    You might also look at how the SideErrorHandler resizes the widget it is owned by to draw an error icon next to a field - the same idea might be possible for ComboBox to avoid (or as part of?) building a new appearance.

  4. #4
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    39
    Vote Rating
    2
    hcr is on a distinguished road

      0  

    Default


    Hi Colin,

    thanks for your reply. I was busy with some other tasks in the meanwhile but I now I managed to get back to my ComboBox. It looks somewhat awkward since the image is outside of the styled combo box but for my purpose this is ok. This way I didn't even had to do any resizing.

    Thanks for your hint on this.

    best regards,
    -hcr-

Thread Participants: 2