on 05-11-2009 10:26 AM
Hi colleagues,
Could any one please let me know how to create tables dynamically
Here what di i mean is :
IF Elements is a node in the context, and it is having 4 attributes, and the values for these attributes are set from the code
for (int j=0; j < Result.size(); j++)
{
IElementsElement element = elementsnode.createAndAddElementsElement();
element.setURL(PatResult.get(j).getURL());
element.setURLLabel(PatResult.get(j).getDLOBJTITLE());
element.setFileName(PatResult.get(j).getFILENAME());
}
if j is 3......Then i need to display three tables on the screen
if j is 2 then two tables
is this possible to do?
Thanks & Regards
Swetha
Hello,
If you want to create the tables dynamically in the layout then write the code in the wddomodify method().
public static void wdDoModifyView(IPrivateTableTestView wdThis, IPrivateTableTestView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
for (int j=0; j < Result.getvalue(); j++)
{
IPrivateTableTestView.IElementsElement element = wdContext.nodeElements().createElementsElement();
element.setUrl("URL" + j);
element.setUrlLabel("UrlLabel" + j);
element.setFileName("FileName" + j);
wdContext.nodeElements().addElement(element);
IWDTable tableDC = (IWDTable) view.createElement(IWDTable.class,"TestTable"+j);
tableDC.bindDataSource(wdContext.nodeElements().getNodeInfo());
IWDTransparentContainer tc =(IWDTransparentContainer)view.getElement("TC_Test");
tc.addChild(tableDC,j);
}
//@@end
}
As shown in the above code dynamically we are creating the tables and number of tables created will depend on the value of the variable j.
Please let me know if you still have any problem.
Sarbjeet Singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srabjeet,
i am doing it like this
for (i=0; i<elementsnode.size(); i++)//size is 4
{
IElementsElement element2 = (IElementsElement) elementsnode.getElementAt(i);
String JobTitle = element2.getURLLabel();
wdComponentAPI.getMessageManager().reportSuccess("Job titile is..........." +JobTitle);
IWDNode iterateElements = wdContext.nodeIterateValues();
IIterateValuesElement iterateelement = (IIterateValuesElement) iterateElements.createAndAddElement();
iterateelement.setDescription(element2.getDescription());
iterateelement.setFileSize(element2.getFileSize());
iterateelement.setURL(element2.getURL());
iterateelement.setURLLabel(element2.getURLLabel());
IWDTable table = (IWDTable) view.createElement(IWDTable.class, null);
table.bindDataSource(wdContext.nodeIterateValues().getNodeInfo());
table.setDisplayEmptyRows(false);
table.setDesign(WDTableDesign.TRANSPARENT);
table.setFixedTableLayout(true);
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("IterateValues.Description");
editor.setWrapping(true);
column.setTableCellEditor(editor);
column.setWidth("50%");
//Create column2
IWDTableColumn column1 = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);
table.addColumn(column1);
//Create 2nd TableCellEditor and bind it to an attribute of the Elements node in the context
IWDTextView editor1 = (IWDTextView) view.createElement(IWDTextView.class, null);
editor1.bindText("IterateValues.FileSize");
column1.setTableCellEditor(editor1);
column1.setHAlign(WDTableColumnHAlign.CENTER);
column1.setWidth("20%");
//Create column3
IWDTableColumn column2 = (IWDTableColumn) view.createElement(IWDTableColumn.class, null);
table.addColumn(column2);
//Create 3rdst TableCellEditor and bind it to an attribute of the Elements node in the context
IWDButton editor2 = (IWDButton) view.createElement(IWDButton.class, null);
editor2.setText("Install");
IWDAction thisAction = view.getAction("GetThesecuritydetails");
editor2.setOnAction(thisAction);
editor2.setVisible(IWDUIElement.DEFAULT_VISIBLE.VISIBLE);
editor2.setEnabled(true);
column2.setHAlign(WDTableColumnHAlign.CENTER);
column2.setTableCellEditor(editor2);
IWDGridData tabledata = table.createLayoutData(IWDGridData.class);
tabledata.setPaddingLeft("10px");
tabledata.setPaddingTop("10px");
TableContainer.addChild(table);
i am getting 4 tables displayed...but all the tables are containing all the values
But what i need is table1 should contain 1st element values
2nd table should contain 2nd elements values...and so on
Please let me know how to achieve this
Thanks & Regards
Swetha
Edited by: Swetha Nellore on May 12, 2009 6:23 AM
Hi swetha,
This is how you need to create tables dynamically and set the property values..
String Table = "Table"+j;
IWDView view = (IWDView) wdControllerAPI;
view.createElement(IWDTable.class,Table);
IWDTable TableUI = (IWDTable)view.getElement(Table);
//For setting the properties of the table..
TableUI.setVisibleRowCount(5);
TableUI.bindDataSource(wdContext.node<node_name>().getNodeInfo().getName());
//Adding it to the root container so that it will be visible..
IWDTransparentContainer Root = (IWDTransparentContainer) view.getElement("RootUIElementContainer");
Root.addChild(TableUI);
Any queries, Revert back.
Best Wishes
Idhaya R
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.