cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Creation of Table and assign Datasource.

Former Member
0 Kudos

Hi Experts

My scenario is like this..

There are more than one RFC models and the output list of these models I need to display in a table format.. The display should happen conditionally as per the availabity of the data in the output list..I need to display the data from multiple models at the same time the said table..

Please let me know the methods to create a table with 5 columns and also how to assign the datasource programatically..

THanks and Regards

SU

Accepted Solutions (1)

Accepted Solutions (1)

former_member365727
Active Contributor
0 Kudos

Hi,

Use only one Table View context.

Model Contexts:


RFC1,           RFC2,            RFC3
I_Attr11         I_Attr21          I_Attr31
I_Attr12         I_Attr22          I_Attr32
I_Attr13         I_Attr23          I_Attr33
I_Attr14         I_Attr24          I_Attr34
I_Attr15         I_Attr25          I_Attr35

Table Control Context:

Table

I_Attr1

I_Attr2

I_Attr3

I_Attr4

I_Attr5

Execute each model individually and loop through all model contexts...append the rows from each model context to table context.


//access the table node
IWDTableNode tableNode = wdContext.nodeTable();
IWDTableElement tableElem;
//loop thugh the models
for(int i=0; i<RFC1.size(); i++)
{
 tableElem = tableNode.createTableElement();
 tableElem.setAttr1(RFC1.getRFC1ElementAt(i).getAttr11);
 tableElem.setAttr2(RFC1.getRFC1ElementAt(i).getAttr12);
 tableElem.setAttr3(RFC1.getRFC1ElementAt(i).getAttr13);
 tableElem.setAttr4(RFC1.getRFC1ElementAt(i).getAttr14);
 tableElem.setAttr5(RFC1.getRFC1ElementAt(i).getAttr15);
 
 tableNode.addElement(tableElem);
}

//similarly loop thrugh the remaining 2 models and append the table context

Regards

Srikanth

Former Member
0 Kudos

HI Srikanth,

Can you explain little more with actual examples.... Please..

Regards

KU

Answers (1)

Answers (1)

monalisa_biswal
Contributor
0 Kudos

Can u describe ur scenario in detail?

If your table structure means no of table columns and column types are not going to modify at runtime then it is not a good idea to create table dynamically.

For Dynamic creation of table and table column you need to write your code inside wdDoModifyView. because you will get reference of view in that method.

IWDTable <tableref> = (IWDTable) view.createElement(IWDTable.class,"<tablename>");

<tableref>.bindDataSource(wdContext.node<node>().getNodeInfo());

IWDTableColumn <colref> =(IWDTableColumn)view.createElement(IWDTableColumn.class,"F");

IWDInputField inf = (IWDInputField )view.createElement(IWDInputField.class,"d");

inf.bindValue(wdContext.node<node>().getNodeInfo().getAttribute("<attribute>"));

<colref>.setTableCellEditor(inf);

<tableref>.addGroupedColumn(<colref>);

IWDTransparentContainer <grp> =(IWDTransparentContainer)view.getElement("RootUIElementContainer");

<grp>.addChild(<tableref>);