cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Dynamic Tables?

Former Member
0 Kudos

Hi,

Anybody has an idea how to add a TextView Element to a TableCellEditor dynamically.

The rest of the stuff like creating a Table, adding a column to it, adding a header to a column, adding a TableCellEditor to a column etc seems straightforward.

Regards

MK

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You cannot "add a TextView Element to a TableCellEditor".

TableCellEditor is a common interface for certain UI elements that may serve as table cell editor.

To set the table cell editor to a TextView for a table column programmatically, use code like

wdDoModifyView():

IWDTableColumn column = (IWDTableColumn) view.getElement("ID-of-column");
IWDTextView editor = (IWDTextView) view.createElement(IWDTextView.class, null);
column.setTableCellEditor(editor);

Armin

Former Member
0 Kudos

Hi Armin,

That was indeed a clue.

But mapping the textview to a node element fetches me the first element repeatedly in all the rows of the table.

editor.bindText("NodeXYZ.ElementXYZ");

Former Member
0 Kudos

MK,

Post your context structure (including cardinality, singleton property, and related attributes)

VS

Former Member
0 Kudos

Hi,

Cardinality 0..n, singleton true

--NodeA

---ElementA1

---ElementA2

Code:

IWDTable testTable = (IWDTable) view.getElement("Table2");

IWDTableColumn testColumn = (IWDTableColumn)view.createElement(IWDTableColumn.class, "TestColumn1");

IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class, null);

textView.bindText("NodeA.ElementA1");

testColumn.setTableCellEditor(textView);

testTable.addColumn( testColumn );

Former Member
0 Kudos

MK,

Everything should work then ( I guess NodeA is direct child of root context node, i.e. so-called independend node).

You may also try this:


textView.bindText
(
  wdContext.getNodeInfo().getChild("NodeA")
    getAttribute("ElementA1")
);

Does it work in this case?

VS

Former Member
0 Kudos

Hi Valery,

The result is identical. It does not work.

Former Member
0 Kudos

MK,

What node is assigned as table data source?

Seems that it is not NodeA...

VS

Former Member
0 Kudos

ya.

Inorder to cross check, i added a column to the table at design time. the result entries in this column are indeed different.

Former Member
0 Kudos

MK,

So your table dataSource is not NodeA. Worse it, NodeA is not event a non-singleton child of table dataSource node. So this is normal table behavior.

You may do the following in your code (wdDoModify):


table.bindDataSource
( 
  wdContext.getNodeInfo().getChild("NodeA") 
);

Now your design-time column will show same entry, but dynamically create column will work correctly.

VS

Former Member
0 Kudos

a slight misunderstanding.

The tables datasource was always NodeA.

The table has a column at design time mapped to an Element of NodeA. The entries in this column are different.

The column which i try to define programmatically has the same entries.

guess, we are back to square 1.

Former Member
0 Kudos

MK,

Yep, we are back ))

I give up!

What SP are you using? Did this behavior reproducible with other controls (say, InputField)?

VS

Former Member
0 Kudos

Hi Valery,

its SP11.

One interesting thing which i observed is that, on manually changing the leadselection of the table, all the

set of similar entries get replaced by another set of similar entries which actually belongs to that lead selection.

Eg:ElementA1

LeadSelection 0:

200001

200001

200001

LeadSelection 1:

200045

200045

200045

LeadSelection2:

200057

200057

200057

Former Member
0 Kudos

Can you please show us the complete context structure of the view controller, and the data binding of the Table UI element.

I guess there is a singleton node involved where there should be a non-singleton.

Armin

Former Member
0 Kudos

Hi Armin n Valery,

It was indeed a singleton/non-singleton issue.

The complete structure was:

.ParentNode(Singleton, 0..n)

..ChildNode(non-singleton, 0..1)

...ChildChildNode(Singleton, 0..n)

And the datasource for the table was the parent node which was incorrect.

Changing the datasource directly to the ChildChildNode solved the problem.

Thank u all.

Answers (0)