Skip to Content
author's profile photo Former Member
Former Member

How to add columns in table via code?

Hi all,

is it possible to add columns in a Web Dynpro table via code? Is there an example how to do this?

Thanks a lot.

Regards

Carsten

Add comment
10|10000 characters needed characters exceeded

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 01, 2004 at 07:32 AM

    Hi Carsten,

    yes this is possible. An example showing the basics is available here: http://help.sap.com/saphelp_nw04/helpdata/en/4f/07cf3dd28b5610e10000000a114084/frameset.htm

    In case of your table, create an instance of IWDTableColumn.class and add it using the addColumn() method of the IWDTable API. This sample uses an InputField as table cell editor:

    IWDTableColumn col = (IWDTableColumn) view.createElement(IWDTableColumn.class, "newcol");
    IWDInputField editor = (IWDInputField) view.createElement(IWDInputField.class, "edit");
    col.setTableCellEditor(editor);
    IWDTable tab = (IWDTable) view.getElement("yourTabName");
    tab.addColumn(col);

    If you don't need specific names for the dynamic created elements, you can use null instead of the names calling the view.createElement() method, then a unique name will be auto-generated.

    Hope that helps.

    Regards

    Stefan

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 01, 2004 at 09:49 AM

    Hi Stefan,

    thanks a lot. I will try it.

    Regards,

    Carsten

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Depending on your use case, it might also be an option to create all needed columns initially and to use the TableColumn.visibility property to show only a subset of the column at a certain point of time.

      Regards, Armin