cancel
Showing results for 
Search instead for 
Did you mean: 

Table binding at runtime

Former Member
0 Kudos

Hi,

I can't find a way to display the data I bound to my table at runtime.

Here's my problem. At the design time, the only thing I have is my table instantiated, nothing else.

There's no way for me to know at design time, the numbers of columns of my table, nor the type of data contained.

Thus, I need to configure all of this programmatically.

I don't know the steps to follow in order to resolve my problem. Here's what I have done so far programmatically. I don't know whether I'm on the right track or not.

1. Create a node

2. For each column, create an attribute with the corresponding type to be displayed (so far, I tried type String and IWDTextView for read only data).

3. For each row, create element and bind it to the node (through createElement() and addElement(). Populate its attribute with data through setAttributeValue()

4. Bind the node to the table through bindDataSource()

In short, when I run my program, I get the number of rows corresponding to the number of elements I instantiated. But no data is displayed. I know I might have to create IWDTableColumn but I don't know how to associate the IWDTableColumn to a specific attribute. And the IWDTableCellEditor object, how do I specify the uielement type to be displayed.

I know I'm lost, that's why I need some help to figure this out!

Thanks in advance,

Alexis Trudeau

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Wow,

thanks for the answer in a so short time delay.

It seems I can't give reward points to any of you... Why?

Former Member
0 Kudos

Because this wasnt marked as a question

Former Member
0 Kudos

Ahh....

Weird, because I never unchecked the Question checkbox...

Alexis

Former Member
0 Kudos

He he he,

Sometimes, Trial and error is worth the take. I found what was my problem. Actually, the interface IWDTableCellEditor is "implemented" by all UIElement.

Therefore, here's what you have to do in order to bind a table from scratch:

1. Create a node associated to your table.

2. Create each attribute associated to each column.

3. For each attribute, create the associated uielement which will be used to display the value of the attribute's element.

4. For each column, create a IWDTableColumn. Set its header with a caption. Set its TableCellEditor with the uielement you just created.

5. add the column to your table.

6. For each row, create each element and set their attributes.

7. Bind the node to the data source of the table.

Voila!

Alexis

P.S. In a short notice, I'll send an example snippet of the code that worked for me.

Former Member
0 Kudos

1. Say you have just created nodeInfo IWDNodeInfo myNI;

2. You bind your table data source to myNI

3. You loop by myNI.iterateAttributes(), on every step you have IWDAttributeInfo myAttr

4. On every step you create table column and table cell editor, in your case IWDTextView myTCE (more on other types later)

5. <b>The missing part</b>: you have to call myTCE.bindText(myAttr) to make any data visible

6. You populate your data via createElement / bindElement. Actually, this step could be performed at any place: before as well as after constructing table

About cell renderers: you could check attribute type for the following:

1. Does it simple type, if no you could not bind it to UI controls at all

2. Does it read-only: if so, you create either read-only controls or TextView for display

3. Does it contains enumeration: if yes, you may bind it to DropDownByKey.

4. Does it boolean: then you may bind it to CheckBox, otherwise to InputField.

All options above may vary, but this is good starting point, IMHO.

Regards,

VS

Former Member
0 Kudos

You are missing the concept of "table cell editor".

The Web Dynpro table UI element works as follows:

- Table needs a data source (context node with cardinality 1:N)

- The attribute values of the data source elements will be displayed in the table columns.

- The node elements will contain the data for the rows.

Each table column has a table cell editor e.g. a TextView. To display the values of attribute "A" of the data source elements, you could

- create a table column

- create a text view

- set it as table cell editor for this table column

- bind the text view property "text" to attribute "A"

All this is normally done in the IDE at design time.

If you only created the table but no columns at design time, you should write in method wdDoModifyView() code like the following:


IWDTable table = (IWDTable) 
  view.getElement(<tableID>);
IWDTableColumn column = (IWDTableColumn)
  view.createElement(IWDTableColumn.class, null);
IWDTextView editor = (IWDTextView) 
  view.createElement(IWDTextView.class, null);
editor.bindText(<path to attribute "A">);
column.setTableCellEditor(editor);
table.addColumn(column);

You can use each UI element that implements interface IWDTableCellEditor as a table cell editor.

Armin