Show TOC Start of Content Area

Procedure documentation Defining Cell Variants  Locate the document in its SAP Library structure

You need the option to select a single cell to provide a value help for individual cells, for example.

The interface TableSingleMarkableCell allows you to group cell variants in any way as you like and to make a single cell selectable in this group. The following example shows how to proceed if you want to implement a selection of a single cell from an entire table.

Prerequisites

You have created an applicaton with a component and view in your Web Dynpro project.

Procedure

Creating the Context

...

       1.      Create a value node TableNode for the data of the table and insert three value attributes of the type String for the table columns.

       2.      Create a value attribute selectedCellVariant of the type String in the TableNode.

       3.      Create a value attribute attributePointer, switch to the Properties, click for the property type, and select the Dictionary Simple Type. Enter com.sap.ide.webdynpro.uielementdefinitions.AttributePointer and confirm with Ok.

This graphic is explained in the accompanying text

Creating the View

...

       1.      Open the context menu in the Outline, select Apply Template and then Table. In the subsequent dialog box from the context, select three attributes for the columns (col1, col2, col3). Confirm by choosing Finish

       2.      Set the property selectionMode of the table to none.

Repeat the steps for each column.

       3.      Highlight the column and open the context menu. Select Insert Cell Variant, TableSingleMarkableCell and confirm with Finish.

       4.      Enter the same value for each TableSingleMarkableCell for the property variantKey - for example, variant1

       5.      Insert a cell editor of the type TextView in each TableSingleMarkableCell.

This graphic is explained in the accompanying text

 

Binding the UI Elements

...

       1.      Bind the text property of each TextView to the column in which the property is contained.

       2.      Bind the attributeToMark property of the corresponding TableSingleMarkableCell to the column in which the element is contained.

       3.      Bind the selectedCellVariant property of each TableColumn to the context attribute selectedCellVariant.

       4.      Add the following source code to the wdDoInit method.

wdDoInit()

1

 

 

2

 

 

 

 

 

 

 

 

3

 

IPrivateUseSingleMarkableCellsView.ItableNodeElement elem;

         int count = 10;

// Fill dummy data

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

              elem = wdContext.nodeTableNode().createTableNodeElement();

              wdContext.nodeTableNode().addElement(elem);

           

              elem.setCol1(“1.” + i);

              elem.setCol2(“2.” + i);

              elem.setCol3(“3.” + i);

// set TableSingleMarkableCell as a variant for the table

              elem.setSelectedCellVariant(“variant1”);

     

 

        }

            For each element that is created in the for loop and is then added, the TableSingle MarkableCell is set as a cell variant in row 3.

Result

Each single cell can be selected separately. You can define an action and in its method, you can determine the coordinates of the currently selected cell using the following code:

IWDAttributePointer attPointer = wdContext.currentContextElement().getAttributePointer();

.

 

End of Content Area