on 06-21-2007 9:03 AM
Hi All,
Im pretty new to WebDynpro can you please help me with some code samples for the below problem,
I have two Collection variables namely, <b>"fieldList"</b> and <b>"Records"</b>
<b>fieldList has the all the field names of the table
Records has all the records in my table</b>
Note : fieldList, Records are dynamic
Now i want to create a table dynamically, with fieldList as the columns and Records as the records inside the table created.
How can we do this please advise
Thanks
Suresh
Depends on what you mean by "dynamically". If the table columns are known at designtime, just create the table in the IDE. The table rows are in any case determined at runtime from the content of the data source node.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suresh Devaiah,
While creating any table you have to take care of the datasource Node.
Now over here since you have a collection field list first iterate through that collection and create the Node Say NodeA as follows:
IWDNodeInfo nodeInfo=wdContext.getNodeInfo().addChild("NodeA",null, true, true, false,false, false, true, null,null, null);
IWDNodeInfo childNodeInfo = wdContext.getChild("NodeA").getNodeInfo();
Collection fieldList; //some collection initialize.
Iterator i = fieldList.iterator();
while(i.hasNext()){
childNodeInfo.addAttribute("Fieldname", "com.sap.dictionary.string"/*Field Type*/);
}
// This has created the node and attributes dynamically at runtime.
//Now populating the node.
Iterator j = childNodeInfo.iterateAttributes();
Collection Records; //initialize the collection
Iterator r = Records.iterator();
while(r.hasNext())
IWDNodeElement nodeElement = wdContext.getChildNode("NodeA").createElement();
while(j.hasNext()){
nodeElement.setAttributeValue(((IWDAttributeInfo)j.next()).getName,"Set the value from the collection");
}
Now in the wdDoModifyView you'll require to do the following under firstTime(default visibility)
if(firstTime){
IWDTable table = (IWDTable)view.createElement(IWDTable.class,"table");
Iterator i = wdContext.getChild("NodeA").getNodeInfo().iterateAttributes();
while(i.hasNext()){
IWDAttributeInfo attInfo = (IWDAttributeInfo)i.next();
IWDTableColumn tableColumn = (IWDTableColumn)view.createElement(IWDTableColumn.class,attInfo.getName()+"column");
IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class,attInfo.getName()+"textView");
textView.bindText(attInfo);
IWDTableStandardCell tableCellEditor = (IWDTableStandardCell)view.createElement(IWDTableCellEditor.class,attInfo.getName()+"editor");
tableCellEditor.setEditor(textView);
textView.setVisible(WDVisibility.VISIBLE);
tableCellEditor.setVariantKey(attInfo.getName()+"i");
tableColumn.addCellVariant(tableCellEditor);
tableColumn.setVisible(WDVisibility.VISIBLE);
}
table.bindDataSource(wdContext.nodeA().getNodeInfo());
IWDTransparentContainer transparentCont = (IWDTransparentContainer)view.getElement("RootUIElementContainer");
transparentCont.addChild(table);
table.setVisible(WDVisibility.VISIBLE);
}
The above code takes care of creating a table dynamically.
Also create some elements for the dataSource node to see the result.
Regards
Amit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
/docs/DOC-8661#34 [original link is broken]
Regards,
Naga
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.