cancel
Showing results for 
Search instead for 
Did you mean: 

How to add columns in table via code?

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Stefan,

thanks a lot. I will try it.

Regards,

Carsten

Former Member
0 Kudos

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

Former Member
0 Kudos

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