I've tried using the DefaultTableViewModel and then just added a DropdownListBox into the constructing Vector. But the DefaultTableModel is running the toString method of the DropdownListBox, so the Cells are filled with "com.sapportals.htmlb.DropdownListBox@50243d".
public TableViewModel getModel(){
Vector rows=new Vector();
Vector headers=new Vector();
headers.add("test");
headers.add("Dropdownlist");
for (int i=0;i<6;i++){
Vector cols=new Vector();
cols.add("test"+i);
cols.add(new DropdownListBox("testddb"+i));
rows.add(cols);
}
DefaultTableViewModel model=new DefaultTableViewModel(rows,headers);
model.getColumn("Dropdownlist").setCellType(1,TableColumnType.USER);
return model;
}
I've got no experience in using a Renderer.
Any sources for sourcecode would be nice to get into the whole thing.
Hi guys,
You have to create a class which will be used to render the USER type cells. The cell renderer class is very simple. Something like this:
package .....
import com.sapportals.htmlb.rendering.*;
import com.sapportals.htmlb.table.ICellRenderer;
import com.sapportals.htmlb.table.TableView;
import com.sapportals.htmlb.DropdownListbox;
import com.sapportals.htmlb.enum.CellHAlign;
public class tableCellRenderer implements ICellRenderer {
public void renderCell (int row, int column, TableView tableView, IPageContext rendererContext) {
if (column == tableView.getColumn("YourColumnTitle").getIndex()) {
DropdownListbox drop = .....
drop.render(rendererContext);
}
}
}
So, with the if condition you identify the column you want and do whatever you like to it.
Back on the component class, you have to get a new instance of the class and tell the tableview about it with:
tableCellRenderer tcr = new tableCellRenderer();
yourTableView.setUserTypeCellRenderer(tcr);
Then declare which columns are USER type with:
yourTableView.getColumn("YourColumn").setType(TableColumnType.USER);
That's it!
Hope it helps!
Cheers
P.
PS: On the DefaultTableViewModel you can only play with the actual data and metadata which the tableview will display. You can't mess around with its looks!
Regards.
Pedro
Finaly I got this whole stuff rendered with the ICellRenderer interface and everything looks like I want it to.
But!!
Now I am trying to implement an eventhandling and I don't get the selected value for the Dropdownlistboxes (DdLB). I'm getting the DdLB as an Object but neither the getValueAsDataType nor the getSelection method do return something different from null.
I don't have any clue what to do to get the value.
Add a comment