on 01-05-2009 1:16 PM
Dear Friends,
I am trying to create columns for a table Dynamically using a loop.
I want to give Column Name in the code below:
column1 = (IWDTableColumn)view.createElement(IWDTableColumn.class, colName);
Giving the column Name is giving exception
com.sap.tc.webdynpro.services.exceptions.WDCreationFailedException: Cannot create view element implementation com.sap.tc.webdynpro.clientserver.uielib.standard.impl.TableColumn
Instead if I use null, it works fine.
As per my requirement, I have to use column name.
Can anybody help me on this.
Many Thanks in Advance.
Lakshmikanthaiah
Hi Lakshmikanth,
Strore all the column names in a String array called colName and try this code,
for(int i=0; i<colName.length;i++)
{
IWDTableColumn column = (IWDTableColumn) view.createElement(IWDTableColumn.class,"ColCaption" +i );
IWDCaption caption = (IWDCaption) view.createElement(IWDCaption.class,"Caption" +i);
caption.setText(colName<i>);
column.setHeader((IWDCaption) caption);
table.addColumn(column);
}
Regards
Kishan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As per my requirement, I have to use column name.
What does that mean? How can the technical ID of a table column be part of your requirement?
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lakshmikanth,
Use the following code instead,
IWDTableColumn column = (IWDTableColumn) view.createElement(IWDTableColumn.class,"ColCaption" );
IWDCaption caption = (IWDCaption) view.createElement(IWDCaption.class,"Caption" );
caption.setText(<colName>);
column.setHeader((IWDCaption) caption);
table.addColumn(column);
The above code adds a column named <colName> to the table.
Regards
Kishan
Edited by: kishan chandranna on Jan 6, 2009 5:28 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
if you are writing the below code in a loop
column1 = (IWDTableColumn)view.createElement(IWDTableColumn.class, colName);
that means you are trying to assign same ID to all the columns which is not possible.
An ID is a unique identifier you need to keep the ID for each column different.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I had seen the following code some where in SDN. I didnot remember the thread. It may be of some usefull for you
// 3. Create Table:
table = (IWDTable)view.createElement(IWDTable.class,"ID");
String[] colHead = {"Master ","Business","Business1"} ;
int count = 0;
IWDTableColumn nameColumn = null;
for (int j = 0; j < 3; j++) {
//4. Create CellEditor (TextView):
//5. Bind attribute to the TextView:
//6. Create Column:
nameColumn = (IWDTableColumn) view.createElement(IWDTableColumn.class, "column"+j);
IWDCaption colHeader = (IWDCaption)view.createElement(IWDCaption.class,"header"+j);
IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class , "text"+j);
colHeader.setText(colHead[j]);
nameColumn.setHeader(colHeader);
textView.setText("");
textView.bindText(wdContext.getChildNode("TableNode",IWDNode.LEAD_SELECTION).getNodeInfo().getAttribute("name"+j));
//7. Set CellEditor of Column:
nameColumn.setTableCellEditor((IWDTextView)textView);
//8. Add the Column to the Table:
table.addColumn(nameColumn);
Regards
Raghu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.