on 04-23-2008 10:35 AM
Hi,
I want to display table in row wise.
Example:
Name Abc Xyz Pqr
Age 25 27 24
Please let me know as how to do this.
Thanks & Regards,
Rajesh A
Hello Rajesh,
Displaying the rows by creating rows Dynamically is a very good way. One alternative way could be rearranging the value in a dummy node the way you wanted and bind it to required table.
Say the original data is in Node : MainNode
Fetch the data from mainNode and Put it in a dummyNode which can be mapped to required table, say FilteredNode.
The code will look like similar to the one below
IFilteredValueElement filteredElement = null;
int mainNodeSize = wdContext.nodeMainNode().size();
String value = "";
for(int column=0 ; column<3 ; column++){
filteredElement = wdContext.createFilteredValueElement();
for(int row=0; row<mainNodeSize;row++){
switch(column){
case 0 : value = wdContext.nodeMainNode().getMainNodeElementAt(row).getFirst();break;
case 1 : value = wdContext.nodeMainNode().getMainNodeElementAt(row).getSecond();break;
case 2 : value = wdContext.nodeMainNode().getMainNodeElementAt(row).getThird();break;
}
switch (row){
case 0: filteredElement.setColumn1(value);break;
case 1: filteredElement.setColumn2(value);break;
case 2: filteredElement.setColumn3(value);break;
}
}
wdContext.nodeFilteredValue().addElement(filteredElement);
}
Bind this FilteredNode to Required Table. But the problem with this is, the cell will have border as it is displayed through tables. and Also the number of rows and number of column should be known. So if this doesnt work out, I would also recommend you to use Dynamic creation of rows.
Hope this helps.
-Shabir Rahim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
one option, cant say it will solve your problem but there is a chance...
Take table as a ROW Layout, The subelement RowHeadData allows you to specify which UI element appears at the start of each new row within the container.
check this link...
http://help.sap.com/saphelp_nw70/helpdata/EN/e2/749141c1d0ae5fe10000000a1550b0/content.htm
it may help you....
regards,
Pradeep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi rajesh,
This can solve ur problem. just check this
This code is provided by Armin in a forum thread but there is some problem & i can't get the link for that thread or thread no. .So i m giving the code directly instead of URL for the thread.
/** armin's comments
In a purely read-only scenario, you can achieve this layout by programatically creating the view.
Suppose you have a context structure like this:
Items (node, 0:N)
name (string)
amount (integer)
Then the following code (note: this is for NW 7.1, for earlier versions, you have to add a cast here and there) creates the wanted layout:
code public static void wdDoModifyView(IPrivateTableRotatedCompView wdThis, IPrivateTableRotatedCompView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
if (firstTime || wdContext.currentContextElement().getItemsChanged())
{
IWDTransparentContainer grid = (IWDTransparentContainer) view.getElement("Grid");
// Headers
{
IWDInvisibleElement emptyCell = view.createElement(IWDInvisibleElement.class);
grid.addChild(emptyCell);
emptyCell.createLayoutData(IWDMatrixHeadData.class);
for (int i = 0; i < wdContext.nodeItems().size(); ++i)
{
IWDTextView columnHeader = view.createElement(IWDTextView.class);
columnHeader.setDesign(WDTextViewDesign.EMPHASIZED);
columnHeader.setText("Item " + i);
grid.addChild(columnHeader);
}
}
// Row 1: item names
{
IWDTextView rowHeader = view.createElement(IWDTextView.class);
grid.addChild(rowHeader);
{
IWDMatrixHeadData layoutData = rowHeader.createLayoutData(IWDMatrixHeadData.class);
}
rowHeader.setDesign(WDTextViewDesign.EMPHASIZED);
rowHeader.setText("Header1");
for (int i = 0; i < wdContext.nodeItems().size(); ++i)
{
IItemsElement item = wdContext.nodeItems().getItemsElementAt(i);
IWDTextView name = view.createElement(IWDTextView.class);
grid.addChild(name);
name.setText(item.getName());
}
}
// Row 2: item amounts
{
IWDTextView rowHeader = view.createElement(IWDTextView.class);
grid.addChild(rowHeader);
IWDMatrixHeadData layoutData = rowHeader.createLayoutData(IWDMatrixHeadData.class);
rowHeader.setDesign(WDTextViewDesign.EMPHASIZED);
rowHeader.setText("Header2");
for (int i = 0; i < wdContext.nodeItems().size(); ++i)
{
IItemsElement item = wdContext.nodeItems().getItemsElementAt(i);
IWDTextView amount = view.createElement(IWDTextView.class);
grid.addChild(amount);
amount.setText(String.valueOf(item.getAmount()));
}
}
wdContext.currentContextElement().setItemsChanged(false);
}
//@@end
}[/code]
regards
Sumit
Hi Sumith,
Thanks for your reply.
As I mentioned earlier, the solution given by you is somewhat similar to what I actually require i.e. displaying table in row wise. Your solution is to generate elements dynamically in the required order. I have not got the complete solution what am expecting. I have kept the thread open in order to get any other alternate answers from the forum.
Regards,
Rajesh A
User | Count |
---|---|
84 | |
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.