Skip to Content
0
Sep 03, 2007 at 01:45 AM

Horizontal table using TableStandardCell dynamically

9 Views

Hi,

I want to make a horizontal table. I searched this forum, I knew a TableStandardCell object.

I make a horizontal table dynamically in the program, because I don't know how many columns is needed.

I made a program like below, but nothing is displayed in the cell. The number of cell is correct.

What is wrong in this program? Please teach me.

If the same procedure is set with GUI, the value(Context) is displayed to the cell.

******************************************************************************

public static void wdDoModifyView(IPrivateSimpleDynamic wdThis, IPrivateSimpleDynamic.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

//@@begin wdDoModifyView

if (firstTime) {

int elementIndex = 0;

// Get a Table Object

IWDTable table = (IWDTable) view.getElement("Table");

// Make a Column

IWDTableColumn tableColumn =

(IWDTableColumn) view.createElement(

IWDTableColumn.class,

"tableCol");

// Context is set to the Column at SelectedCellVariant property

tableColumn.setSelectedCellVariant("disp.selectedCellVariant");

// Make a TableStandardCell

IWDTableStandardCell stanCell =

(IWDTableStandardCell) view.createElement(

IWDTableStandardCell.class,

"standardCell" + elementIndex);

// VariantKey is named

stanCell.setVariantKey("textview");

// Make a TextView

IWDTextView textView =

(IWDTextView) view.createElement(

IWDTextView.class,

"textView");

// Context is set to the TextView

textView.bindText("disp.col0");

textView.setVisible(WDVisibility.VISIBLE);

// The TextView is specified for the TableStandardCell

stanCell.setEditor(textView);

// The TableStandardCell is added to the Column

tableColumn.addCellVariant(stanCell);

tableColumn.setVisible(WDVisibility.VISIBLE);

// The Column is added to the Table.

table.addColumn(tableColumn);

table.setVisible(WDVisibility.VISIBLE);

// Bind the DataSource to the Table

table.bindDataSource(wdContext.nodeDisp().getNodeInfo());

}

//@@end

}

  • The attribute of "SelectedCellVariant" in the Context is set to the value "textview".

disp.setSelectedCellVariant("textview");