cancel
Showing results for 
Search instead for 
Did you mean: 

Create Dynamic Table

Former Member
0 Kudos

Hi Colleagues,

Could anyone please let me know how to create dynamic table

Here my requirement is The table should have number of rows depending on the node size

IF the node size is 2 the table should have 2 rows

Please let me know how to proceed

Thanks & Regards

Swetha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If your requirement is to create a table and to bind the node to that table dynamically.

Then go throgh the tutorial "Dynamic Programming of Web Dynpro Applications" in the below link

/docs/DOC-8061#34 [original link is broken]

Irrespective of Dynamic or Design time you can control the row count of the table by the MaxVisibleRows property of the table.

You can set the value of this MaxVisibleRows property dynamically with the value of the size of the node.

Regards,

Charan

Former Member
0 Kudos

Hi Charan,

Thankyou for the reply

i have used the following code for the dynamic table creation

but somehow it is giving the following error

com.sap.tc.webdynpro.progmodel.context.ContextException: NodeInfo(path=Chekpreq/ChekpreqView, class=com.sap.tc.webdynpro.progmodel.context.DataNodeInfo): unknown child node Prerequisites

code i have used

IWDTransparentContainer TableContainer = (IWDTransparentContainer)view.createElement(IWDTransparentContainer.class);
	  IWDGridLayout TableLayout =(IWDGridLayout) TableContainer.createLayout(IWDGridLayout.class);
	  
	  IWDTable table = (IWDTable) view.createElement(IWDTable.class, null); 
	  table.bindDataSource("Prerequisites");
	  table.setDisplayEmptyRows(false);
	  table.setDesign(WDTableDesign.TRANSPARENT);
	  table.setFixedTableLayout(true);
	  table.setVisibleRowCount(wdContext.nodePrerequisites().size());
	  table.setRowSelectable(false);
	  WDTableGridMode mode = WDTableGridMode.NONE;
	  table.setGridMode(mode);
	  WDTableSelectionMode sm = WDTableSelectionMode.NONE;
	  table.setSelectionMode(sm);

//Create column1

IWDTableColumn column = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);
	  table.addColumn(column);			
	  //Create 1st TableCellEditor and bind it to an attribute of the Elements node in the context 
	  IWDTextView editor = (IWDTextView) view.createElement(IWDTextView.class, null);
	  editor.bindText("Prerequisites.title");
	  editor.setWrapping(true);
	  column.setTableCellEditor(editor);
	  column.setWidth("50%");

Could you please let me know where i am going worng

in the context...i have "Prerequisites" as a node and "link" and "title" are the attributes

Thanks & Regards

Swetha

Edited by: Swetha Nellore on Jun 15, 2009 3:21 PM

Edited by: Swetha Nellore on Jun 15, 2009 3:22 PM

Former Member
0 Kudos

Can you try replacing this line table.bindDataSource("Prerequisites");

with the following two lines.

	IWDNodeInfo nodeInfo = wdContext.getNodeInfo().getChild("Prerequisites")
                table.bindDataSource(nodeInfo)

Former Member
0 Kudos

Hi,

Modify your code as below:

IWDTransparentContainer TableContainer = (IWDTransparentContainer)view.createElement(IWDTransparentContainer.class,"TC1");
IWDGridLayout TableLayout =(IWDGridLayout) TableContainer.createLayout(IWDGridLayout.class);

//Getting the root container and adding the transparent container to that root container
IWDTransparentContainer  rootUIElementContainer= (IWDTransparentContainer)view.getElement("RootUIElementContainer");
rootUIElementContainer.addChild(TableContainer);
		
IWDTable table = (IWDTable) view.createElement(IWDTable.class, "NewTable"); 
 table.bindDataSource("Prerequisites");
 //table.setDisplayEmptyRows(false);
 table.setDesign(WDTableDesign.TRANSPARENT);
 table.setFixedTableLayout(true);
 table.setVisibleRowCount(wdContext.nodePrerequisites().size());
 table.setRowSelectable(false);
 WDTableGridMode mode = WDTableGridMode.NONE;
 table.setGridMode(mode);
 WDTableSelectionMode sm = WDTableSelectionMode.NONE;
 table.setSelectionMode(sm);

// Create column1 

 IWDTableColumn column = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);
  table.addColumn(column);			

  //Create 1st TableCellEditor and bind it to an attribute of the Elements node in the context 
  IWDTextView editor = (IWDTextView) view.createElement(IWDTextView.class, null);
  editor.bindText("Prerequisites.title");
  editor.setWrapping(true);
  column.setTableCellEditor(editor);
  column.setWidth("50%");
				  
 //Adding table to Transparent container				  
  TableContainer.addChild(table);

Note: Check you have created the node in the root context with exactly same name as "Prerequisites".

Regards,

Charan

Former Member
0 Kudos

Hi Santhosh,

Do i need to change something while binding text to the cell editor?

or is it the same

Editor.bindText("Prerequisites.title");

Please let me know

Thanks & Regards

Swetha

Former Member
0 Kudos

It seems you have got it working

bindText can also be used similar to the one which I mentioned earlier.

See below

IWDNodeInfo nodeInfo = wdContext.getNodeInfo().getChild("Prerequisites")
IWDAttributeInfo attribInfo = nodeInfo.getAttribute(title);
Editor.bindText(attribInfo);

Please note this is an untested code,might be some syntax errors exist

Former Member
0 Kudos

Hi Santhosh,

Here in the table that got created the second column should contain the links

the code which i have used is

IWDTableColumn column1 = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);
	  table.addColumn(column1);	
	  IWDCaption Col2header = (IWDCaption) view.createElement(IWDCaption.class, null);	
	  Col2header.setText("Download Link");
	  column1.setHeader(Col2header);
	  column1.setWidth("60%");
	  
	  IWDLinkToURL editor1 = (IWDLinkToURL) view.createElement(IWDLinkToURL.class, null);
	  //IWDTextView editor1 = (IWDTextView) view.createElement(IWDTextView.class, null);
	  editor1.bindText("prerequisites.link");
	   column1.setTableCellEditor(editor1);

	  
	  TableContainer.addChild(table);

But for the above code....the link is not selectable....How can i get the link selectable in atable

Can you please help me here

Thanks & Regards

Swetha

Former Member
0 Kudos

Hi,

To get the link you need to bind to reference property of LInkToURL.

editor1.setReference("prerequisites.link");

Regards,

Charan

Former Member
0 Kudos

Hi Swetha,

Instead of binding the editor1 link to text,bind it to reference.

So add editor1.bindReference("prerequisites.link") to ur code as follows

IWDLinkToURL editor1 = (IWDLinkToURL) view.createElement(IWDLinkToURL.class, null);
editor1.bindReference("prerequisites.link");
column1.setTableCellEditor(editor1);

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Swetha,

just assign node size variable to "VisibleRowCount" property.

Regards,

Sunaina Reddy T

Former Member
0 Kudos

Do you mean you want to create using table?

But for your requirement you do not need dymanic table.

Instead create a table at design time and bind a context variable(say RowCount) of type integer to the VisibleRowCount property of the table.

And set the RowCount context variable equivalent to Size of the node.

hope it helps.Let me know if u need more help