on 09-20-2006 1:41 PM
Hi,
I have a raq that I need to create a table Dynamically
with 3columns and 2rows. The rows should be extended dynamically.
Please help me with necessay coding and necesary steps.
Its very very urgent.
Hi ,
This is the code for Dynamic table creation
Have look at the following sample code. and try it with your own data. this will create a table and context node and attributes for that table dynamically.
IWDTransparentContainer rootElement = (IWDTransparentContainer)view.getRootElement();
IWDNodeInfo tabNode=wdContext.getNodeInfo().addChild("Tab_Node",null,true,true,true,false,true,false,null,null,null);
IWDAttributeInfo tabAttrib_Name=tabNode.addAttribute("Name","ddic:com.sap.dictionary.string");
IWDAttributeInfo tabAttrib_Add=tabNode.addAttribute("Address","ddic:com.sap.dictionary.string");
IWDTable tab=(IWDTable)view.createElement(IWDTable.class,"Dyntable");
IWDAttributeInfo attrib1=tabNode.getAttribute("Name");
IWDAttributeInfo attrib2=tabNode.getAttribute("Address");
tab.bindDataSource(tabNode);
tab.setCompatibilityMode(WDTableCompatibilityMode.AUTO);
tab.setDesign(WDTableDesign.ALTERNATING);
IWDTableColumn tabColumn1=(IWDTableColumn)view.createElement(IWDTableColumn.class,"NameCol");
IWDTableColumn tabColumn2=(IWDTableColumn)view.createElement(IWDTableColumn.class,"AddressCol");
IWDCaption nameCap=(IWDCaption)view.createElement(IWDCaption.class,"nameCap");
nameCap.setText("Name");
tabColumn1.setHeader((IWDCaption)nameCap);
IWDCaption addCap=(IWDCaption)view.createElement(IWDCaption.class,"addCap");
addCap.setText("Address");
tabColumn2.setHeader((IWDCaption)addCap);
IWDInputField nameText=(IWDInputField)view.createElement(IWDInputField.class,"nameText");
nameText.bindValue(attrib1);
tabColumn1.setTableCellEditor((IWDTableCellEditor)nameText);
IWDInputField addText=(IWDInputField)view.createElement(IWDInputField.class,"addText");
addText.bindValue(attrib2);
tabColumn2.setTableCellEditor((IWDTableCellEditor)addText);
tab.addColumn(tabColumn1);
tab.addColumn(tabColumn2);
tab.createLayoutData(IWDRowHeadData.class);
tab.setWidth("300");
IWDNode dynTabNode=(IWDNode)wdContext.getChildNode("Tab_Node",0);
for(int i=0; i<5;i++)
{
IWDNodeElement dynTabElem=(IWDNodeElement)dynTabNode.createElement();
dynTabElem.setAttributeValue("Name","Karthik");
dynTabElem.setAttributeValue("Address","Chennai");
dynTabNode.addElement(dynTabElem);
}
rootElement.addChild(tab);
// you should create one action for the table lead selection
IWDAction tabact=(IWDAction)wdThis.wdGet<Actionname>();
tab.setOnLeadSelect(tabact);
Also refer this link
Regards,
Saraswathi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Srinivas,
As Valery said, create TABLE UI .. create the 3 columns .. bind dataSource of Table and relevant properties..Populate the context with 2 rows.
You can create a valueAttribute say <i>tableVisibility</i> (of type com.sap.ide.webdynpro.uielementdefinitions.Visibility) and bind it to the '<b>visible</b>' property of the table.
Initially, set the tableVisibility to NONE.
wdContext.currentContextElement().setTableVisibility(WDVisibility.NONE);
After populating, you set the visibility of the table to "<b>VISIBLE</b>" using the contextelement (=tableVisibility)
wdContext.currentContextElement().setTableVisibility(WDVisibility.VISIBLE);
Did you try like this?
<b>[OR]</b>
Check this thread for dynamic table creation:
Hope it helps.
Regards,
SK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Srinivas,
There is no "dynamic" code in this case.
Create Table UI control, create necessary 3 columns with corresponding cell editors, bind dataSource of table and relevant properties of cell editors to corresponding context node / attributes. Then just populate context node with 2 elements (rows).
Better explanation could be found in Table tutorial on SDN, see SAP NetWeaver / Application Server / Web Dynpro section.
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.