Skip to Content
author's profile photo
Former Member

Dropdownlistbox in a TableView

Hello everyone

I am trying to put a DropdownListBox into one column of a TableView, but I am having no success in that. So would anyone be so kind to give me any hint in how you can do this.

Thanks

Boris

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

7 Answers

  • author's profile photo
    Former Member
    Mar 25, 2004 at 08:58 AM

    Can you submit some code?

    BTW, The cells datatype must be com.sapportals.htmlb.enum.TableColumnType.USERfor dropdowns.

    Regards.

    /Fredrik

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Mar 25, 2004 at 12:00 PM

    Did you try using CellRenderer?

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Mar 25, 2004 at 12:37 PM

    I've tried using the DefaultTableViewModel and then just added a DropdownListBox into the constructing Vector. But the DefaultTableModel is running the toString method of the DropdownListBox, so the Cells are filled with "com.sapportals.htmlb.DropdownListBox@50243d".

    public TableViewModel getModel(){

    Vector rows=new Vector();

    Vector headers=new Vector();

    headers.add("test");

    headers.add("Dropdownlist");

    for (int i=0;i<6;i++){

    Vector cols=new Vector();

    cols.add("test"+i);

    cols.add(new DropdownListBox("testddb"+i));

    rows.add(cols);

    }

    DefaultTableViewModel model=new DefaultTableViewModel(rows,headers);

    model.getColumn("Dropdownlist").setCellType(1,TableColumnType.USER);

    return model;

    }

    I've got no experience in using a Renderer.

    Any sources for sourcecode would be nice to get into the whole thing.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      What if you replace the line

      model.getColumn("Dropdownlist").setCellType(1,TableColumnType.USER);

      with

      model.getColumn("Dropdownlist").setType(TableColumnType.USER);

      Will that work?

      /Fredrik

  • author's profile photo
    Former Member
    Mar 25, 2004 at 03:32 PM

    Threre are no Changes, if I try to set the TableColumnType for the hole Column. I am actually trying to use my own Renderer Class. But still got no success. 😔

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I have the same problem with image-objects, so if anyone could submit working examples using TableColumnType.USER it would be HIGHLY apreciated.

      FYI: The reason why I try to use USER instead of IMAGE or IMAGELINK as TableColumnType, is to find a way to set the size of the image-object(the goal is a kind of thumbnail-presentation). With IMAGE and IMAGELINK the images are shown with their real size.

  • Mar 30, 2004 at 03:36 PM

    Hi guys,

    You have to create a class which will be used to render the USER type cells. The cell renderer class is very simple. Something like this:

    package .....

    import com.sapportals.htmlb.rendering.*;

    import com.sapportals.htmlb.table.ICellRenderer;

    import com.sapportals.htmlb.table.TableView;

    import com.sapportals.htmlb.DropdownListbox;

    import com.sapportals.htmlb.enum.CellHAlign;

    public class tableCellRenderer implements ICellRenderer {

    public void renderCell (int row, int column, TableView tableView, IPageContext rendererContext) {

    if (column == tableView.getColumn("YourColumnTitle").getIndex()) {

    DropdownListbox drop = .....

    drop.render(rendererContext);

    }

    }

    }

    So, with the if condition you identify the column you want and do whatever you like to it.

    Back on the component class, you have to get a new instance of the class and tell the tableview about it with:

    tableCellRenderer tcr = new tableCellRenderer();

    yourTableView.setUserTypeCellRenderer(tcr);

    Then declare which columns are USER type with:

    yourTableView.getColumn("YourColumn").setType(TableColumnType.USER);

    That's it!

    Hope it helps!

    Cheers

    P.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 30, 2004 at 03:41 PM

    PS: On the DefaultTableViewModel you can only play with the actual data and metadata which the tableview will display. You can't mess around with its looks!

    Regards.

    Pedro

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Apr 02, 2004 at 12:55 PM

    Finaly I got this whole stuff rendered with the ICellRenderer interface and everything looks like I want it to.

    But!!

    Now I am trying to implement an eventhandling and I don't get the selected value for the Dropdownlistboxes (DdLB). I'm getting the DdLB as an Object but neither the getValueAsDataType nor the getSelection method do return something different from null.

    I don't have any clue what to do to get the value.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Boris,

      Try using

      context.getDataForComponentId ("tableviewId", "DropdownListBoxID", position)

      where position is the table row.

      Pay attention to the tableView and the DdLB IDs! You have to use the same id you used when the objects were created or it will return null, of course.

      Cheers!

      Pedro