DataContainer include Embedded

Hi,

i have a table, which be filled with a data container. Now i will try to change values from string to a embedded (image). I read something about speacial generated Columns. But i will automaticly change this and is it possible to set the Embedded in DataContainer?
Or is there a another way to fix this problem?

Thanks
Dominik

As I understand, you have String in your data container, but you want to show image instead of String. In this case, you can use Table.ColumnGenerator and implement this method:

generateCell(Table source, Object itemId, Object columnId) 

Using ColumnGenerator you can specify how certain cells are rendered by returning custom component in generateCell method.

Okay that sounds good and have tested it straight.

I created a class an implements the ColumnGenerator. In the generateCell-Methode implements this:

		String res = "Test";
		System.out.println("GenerateCell");
return res;

Only set a test value and print a test. At the end i will give it back.
And after that i added it to the table:

PD_VColumnlmageGenerator generator = new PD_VColumnlmageGenerator(this);
		this.table.addGeneratedColumn(5, generator);

But it won´t works? Where is my mistake ?

From your code I cannot see what is wrong (not enough code provided). But I can give you a small example:

Table table = new Table();
table.addContainerProperty("TestColumn", String.class, null);
table.addItem(new Object[]{"string 1"},1);
table.addItem(new Object[]{"string 2"},2);
		
Table.ColumnGenerator cg = new Table.ColumnGenerator() {
	@Override
	public Object generateCell(Table source, Object itemId, Object columnId) {
		Object text = source.getItem(itemId).getItemProperty(columnId).getValue();
		return new Button(text.toString());
	}
};
		
table.addGeneratedColumn("TestColumn", cg);

It replaces two strings with two buttons. I hope this example helps you to find out what was wrong in your code.

First sorry that i answer so late.
Okay it works but i think this can´t be the solution for my problem. I need to insert the generated Column in the value of columns that existing from a container. So i would replace a existing column in container or table and set at this index a own created column.
Do you know what i mean?

Dominik Grimmeisen

Maybe I don’t understand your comment correctly, but if you want to “replace” a container column with a generated one that presents the same data differently, that is exactly what Mindaugas’ example does. To do that, you just need to use the same column id for your generated column as for the container column and the generated column will “replace” the other one.