How to create multiline ListBox in GWT?


Tags: html,css,gwt

Problem :

In my project the value to show in GWT list-box is big(from database). So user is not able to see the full value at once. For this I have decided to add display value in multiline. I have used tags like \n and HTML tags like breakline but not getting the result. GWT compiler considering these tags as a string and showing in the list. How can I do this. Can I apply customized css?

My code is as below:

ListBox getListBox(boolean dropdown) {

  String longText = "AAAAAAAAAAAAAAAAAAAA BBBBBBBBBBBBBBBBBBBB CCCCCCCCCCCCCCCCCCCC";

  ListBox widget = new ListBox();
  widget.addStyleName("demo-ListBox");
  widget.addItem(longText);
  widget.addItem("Two");
  widget.addItem("Three");
  widget.addItem("Four");
  if(!dropdown)widget.setVisibleItemCount(3);
    return widget;
}


Solution :

GWT ListBox simply wraps an HTML select element. Such element does not allow line breaks in its option values.

You can:

  • change approach: use a short description with a longer title attribute;
  • roll out your own widget, or use one already available (like the new GwtChosen).

    CSS Howto..

    How to build some basic tiles with Title and Description?

    How can I make all table cell sizes the same width in css?

    how to set a fixed width to textbox which wont be affected by varying value of padding-left?

    CSS - How to make a div as wide as a containing child img

    How can I incorporate a slideshow into HTML?

    How do I adjust triangle in css price tag to the right size

    how does responsive design work?

    How to change color of Bootstrap warning class table row

    How to set jquery ui icon as background image per css?

    How to debug CSS with Firebug for an element that only appears when clicked?

    Magento - how to locate the location of inline css

    How to achieve this CSS layout - Answered [closed]

    how to set max size of a counter?

    How to place an image properly with CSS

    How do I change the background on mouse over immediately?

    How to select the first element from a selection when one element does not have a class via CSS?

    How to combine 2 SASS functions as they do almost the same thing just using a different calculation?

    How can I make images stack on top of each other as web page scales down?

    How to reference all the rows except the first one using css

    show one div but hide all other divs is not working

    how to put 2 css elements in the same row (one next to each other)?

    How to center a CSS Hexagon

    How do I keep floated child divs from wrapping?

    How to make my first-child in css work properly?

    How to implement easeOutBack easing in css transform animation

    How to add Bootstrap to Fullpage.js

    How to keep control-specific css with the control code (ASP.NET)

    How to reload or rerender CSS for a single HTML element? [duplicate]

    How to enable CSS editing in Intellij

    CSS HTML - How to add more outer colour on the drop down menus and more than one word per drop down