Show TOC

 Defining Cell Variants Using the Example TableStandardCellLocate this document in the navigation structure

You need the option to have different cell editors in different rows of one column. The following example shows how to proceed if you want to implement an InputField instead of a TextView in the first table row.

Prerequisites
  • You have created an application with the necessary units in your Web Dynpro DC.
  • You have created a context node and attributes for the table data.
  • You have created a table UI element with it's containing elements as described in Implementing Tables .
Procedure
  1. Create a context attribute called selectedCellVariant of the type String in the context node that holds the table data.
  2. Select the column where you need the cell variant and open the context menu. Select Insert Cell Variant, then TableStandardCelland confirm with Finish.
  3. Set the variantKey property of this TableStandardCellto variant1 .
  4. Insert a cell editor of the type InputField in this TableStandardCell. The screenshot shows the table structure in the Outline.

  1. Bind the selectedCellVariant property of the TableColumn to the context attribute selectedCellVariant.
  2. Add the following source code to the wdDoInit method.

    wdDoInit()

     

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

    ITableElement elem = wdContext.createAndAddTableElement();

    elem.setCol1("some content for column 1" );

    if(i==0)elem.setCellVariant("variant1");

    else elem.setCellVariant("");

    }

    The first node element's cell variant is set to variant1 and this is what you have defined as variantKey for the TableStandardCell. For the other elements an empty string is set. This means that no variant is set and these rows are displayed with the TableColumn'scell editor.

Result

As shown in the screenshot below, the first row is displayed with an InputField and the other rows with a TextView.