cancel
Showing results for 
Search instead for 
Did you mean: 

bind node to table at runtime

Former Member
0 Kudos

Hi,

I have a table in webdynpro to which i want to bind a node at runtime. The node is created at run time but the table already exists.

How do i achieve this?

Malita

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos
void wdDoModifyView(...)
{
  if (<not_yet_bound>)
  {
    IWDNodeInfo nodeInfo = wdContext.getRootNodeInfo().getChild(<name of data source node>);
    IWDTable table = (IWDTable) view.getElement(<ID of table>);
    table.bindDataSource(nodeInfo);
    /* bind editor, say InputField, of first table column */
    IWDInputField editor = (IWDInputField) view.getElement(<ID of editor>);
    editor.bindValue(nodeInfo.getAttribute(<name of edited attribute>));
    /* and so on... */
  }
}

Armin

former_member751941
Active Contributor
0 Kudos

Hi Malati,

Check this.

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6fdae690-0201-0010-a580-d104b459cb44">Dynamically Creating, Building and Mapping a Context in Web Dynpro</a>

Regards,

Mithu

Former Member
0 Kudos

Hi

Use the following

IWDTable iTab = (IWDTable)view.getElement("Table"); // your table

iTab.bindDataSource("Root"); // the context path of the attribute

following are the different variants of the bind method.

public void bindDataSource(String path);

public void bindDataSource(IWDNodeInfo nodeInfo);

Regards

Ayyapparaj

Former Member
0 Kudos

Will the attributes also bind to the colums using this?

Former Member
0 Kudos

Hi,

Sample Code to bind a Node to a table with all attributes.

IWDTransparentContainer container = (IWDTransparentContainer)view.getElement("RootUIElementContainer");

container.destroyAllChildren();

IWDTable iTab = (IWDTable)view.createElement(IWDTable.class,null);

iTab.bindDataSource("Root");

Iterator itr1 = wdContext.getChildNode("Root",0).getNodeInfo().iterateAttributes();

while(itr1.hasNext())

{

IWDTableColumn iTabCol = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);

IWDInputField input= (IWDInputField)view.createElement(IWDInputField.class,null);

IWDAttributeInfo iWDInfo = (IWDAttributeInfo) itr1.next();

input.bindValue("Root."+iWDInfo.getName());

iTabCol.setTableCellEditor(input);

IWDCaption iCap = (IWDCaption) view.createElement(IWDCaption.class, null);

iCap.setText(iWDInfo.getName());

iTabCol.setHeader(iCap);

iTab.addGroupedColumn(iTabCol);

}

container.addChild(iTab);

REgards

Ayyapparaj

Former Member
0 Kudos

wont this code create a new table?

Former Member
0 Kudos

Hi

Yes it will Its provided as a reference for you to align to your requirement

Regards

Ayyapparaj