cancel
Showing results for 
Search instead for 
Did you mean: 

Horizontal table with checkboxes

Former Member
0 Kudos

Hi,

I need to create a horizontal table. With this i mean the column aren't on top but on the left side and the data goed from top to bottom. You often see this construction to make it easy for user to compare values. I also need to display in the last row for every column a checkbox.....as to select that data column

Something like this:


              | X | Y |
------------------------
 name     |    |    |
------------------------
 descr     |    |    |
-------------------------
              | 0 | 0  |

I managed to create the table dynamically but i cant seem to find a way to a the checkboxes because the go by column and not by row. I tried adding them in a seperate container underneath but i can't seem to get hold of the column widths at runtime.

Another possibility which i thought maybe would work, is not to work with a table but to simulate this and just create it with a container with Gridlayout and filling it like a grid. Dont know if this woulr workd though...

Any thoughts or idea's?

Much thanks & regards,

Hugo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Hugo Hendriks,

This is a very good point.

Such tables will become very important when it comes to the comparison.I tried it out on a basic level and it worked.Following is the approach that I followed:

1. Create a table dynamically bind it to the data source(Which I created statically as DataSource).

2.Now there i started traversing through the node i.e the source and adding the Standard Cell Editors as AbstractVariants for each type following is the code to do that(For check BOX):

IWDCheckBox checkBox = (IWDCheckBox)view.createElement(IWDCheckBox.class,"checkBox");
					checkBox.bindChecked(attInfo);
					checkBox.setVisible(WDVisibility.VISIBLE);
					cellEditor.setEditor(checkBox);
					column.addCellVariant(cellEditor);

Once this creational work is done we face the problem of getting access to the column. For this I found that there is a parameter in the leadSelect event that will gives the column position.I hope this solves the issue.

Regards

Amit

    • Reward point if found useful

Former Member
0 Kudos

Hi Amit,

I get your point untill traversing through the node and andding standard cell editors as AbstractVariants. I never worked with AbstractVariants so im kinda lost. Can you be more specific with some more code please?

Much thanks!

regards,

Hugo

Former Member
0 Kudos

Hi Hugo.

you can not use a different editor in the same table column.

I think the only solution is really using a GridLayout or MatrixLayout or similar and than create every cell dynamically. We did a similar thing when the WebDynpro table was not flexible enough. Depending on the amount of data in the table it may become big (and slow) though.

Regards

Bruno

Former Member
0 Kudos

"you can not use a different editor in the same table column."

This was true in NW04, but this restriction has gone with NW04s. There you can use different "table cell variants" in a table column.

Armin

Former Member
0 Kudos

Im working with NW04 so I guess I have to go for the GridLayout or change the requirements...

Thanks & regards,

Hugo

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Hugo,

This is the complete code for achiving a simple sceanrio where you would have

both checkBox and textview in the same column.


if(firstTime)
    {
    	int elementIndex =0;
    	IWDTable table = (IWDTable)view.getElement("Table");
    	for(int i=0;i<wdContext.nodeTableNode().size();i++){
    	IWDTableColumn tableColumn = (IWDTableColumn)view.createElement(IWDTableColumn.class,"tableCol"+elementIndex+i);
		elementIndex++;
    	Iterator iterator = wdContext.nodeTableNode().getNodeInfo().iterateAttributes();
    	while(iterator.hasNext()){
			IWDAttributeInfo attInfo = (IWDAttributeInfo)iterator.next();
			IPrivateAView.ITableNodeElement tableNodeElement = wdContext.nodeTableNode().getTableNodeElementAt(i);
			IWDTableStandardCell stanCell = (IWDTableStandardCell)view.createElement(IWDTableStandardCell.class,"standardCell"+elementIndex);
			elementIndex++;	
    		if(attInfo.getDataType().getLocalName().equalsIgnoreCase("string")){
				IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class,"textView"+elementIndex);
				textView.bindText(attInfo);
				textView.setVisible(WDVisibility.VISIBLE);
				elementIndex++;
				stanCell.setEditor(textView);
				stanCell.setVariantKey(elementIndex+ "String");
    		}
    		else{
				IWDCheckBox checkBox = (IWDCheckBox)view.createElement(IWDCheckBox.class,"checkBox"+elementIndex);
				checkBox.bindChecked(attInfo);
				checkBox.setVisible(WDVisibility.VISIBLE);
				elementIndex++;
				stanCell.setEditor(checkBox);
				stanCell.setVariantKey(elementIndex+ "Boolean");
			}
			tableColumn.addCellVariant(stanCell);
			}
			tableColumn.setVisible(WDVisibility.VISIBLE);
			table.addColumn(tableColumn);
    	}
    	table.bindDataSource(wdContext.nodeTableNode().getNodeInfo());
    }

Regarding the the data source in this case you can create a node i.e table Node with least an attribute of type String and another of type boolean.Create and add

node elements in wdDoInit() for the same.

Regards

Amit