Hi All,
I have lokeed for this specific problem in the forum but couldn’t find any answer, here is the situation.
I have a table, (which seems to be ignoring all my directives related to column width) but anyway that is not issue, the thing is that when the Table is empty, it has certain width for the columns. Right after I add the first item to the table, it resizes the width of the columns, and this ‘resizing effect’ doesn’t look good at all.
Is there a way to fix the width of the columns in a table so it doesn’t resize when an item is added??
Thanks in advance!
This is the code in my app:
tbl_asignacionPlazos = new Table();
tbl_asignacionPlazos.setEditable(false);
tbl_asignacionPlazos.setWidth("100%");
tbl_asignacionPlazos.setHeight("200px");
tbl_asignacionPlazos.addContainerProperty("Day", String.class, null);
tbl_asignacionPlazos.addContainerProperty("Week", String.class, null);
tbl_asignacionPlazos.addContainerProperty("Delete", Button.class, null);
tbl_asignacionPlazos.addContainerProperty("Edit", Button.class, null);
And then this is the code for adding items to table, this method is linked to an “add” button… I needed to rewrite all those createField methods so I could have specific cells editable and button with edit/delete actions for an specific row. I don’t know if this could be affecting the table performance.
private void addItemToTable(String dias, String porcentaje) {
final Button btn_deleteItem = new Button();
btn_deleteItem.setIcon(new ThemeResource("images/icons/delete_small.png"));
btn_deleteItem.setData(itemTableID);
btn_deleteItem.addListener(new Button.ClickListener() {
private static final long serialVersionUID = -3305187823974671807L;
public void buttonClick(ClickEvent event) {
tbl_asignacionPlazos.removeItem(btn_deleteItem.getData());
}
});
final Button btn_editItem = new Button();
btn_editItem.setIcon(new ThemeResource("images/icons/edit_small.png"));
btn_editItem.setData(itemTableID);
btn_editItem.addListener(new Button.ClickListener() {
private static final long serialVersionUID = -5705679320532993245L;
public void buttonClick(final ClickEvent event) {
tbl_asignacionPlazos.setEditable(true);
tbl_asignacionPlazos.setTableFieldFactory(new TableFieldFactory() {
private static final long serialVersionUID = 3515162501766841315L;
public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) {
Integer idItem = (Integer) itemId;
if (event.getButton().getData().equals(idItem)) {
if (propertyId.toString().equals("Dia") || propertyId.toString().equals("Porcentaje")) {
return DefaultFieldFactory.get().createField(container, itemId, propertyId, uiContext);
}
}
return UIUtils.createFieldReadOnly(container, itemId, propertyId, uiContext);
}
});
}
});
tbl_asignacionPlazos.addItem(new Object[] { dias, porcentaje, btn_deleteItem, btn_editItem }, new Integer(itemTableID));
itemTableID++;
}