[neon] is there a new way of setting "checked"-status for table rows in neon? [solved] [message #1754410] |
Fri, 17 February 2017 12:14 |
Nils S Messages: 2 Registered: February 2017 |
Junior Member |
|
|
Hello
We've recently migrated from Mars to Neon and now some code that sets the "checked"-status for newly-created table rows has stopped working.
Previously, when creating table rows from data we could just use the checkRow method of the table like so:
table.checkRow(row, dto.isSelected());
This now results in the checked-status not being set and an IllegalArgumentException ("... only accept InternalTableRow, not class org.eclipse.scout.rt.client.ui.basic.table.TableRow ...") being thrown.
My first idea was that maybe I needed to add the row to the table before checking it (in Mars, you could check rows that were not in the table) but that does not work either.
Sooo... is there a new way to do this? Or some kind of trick to get it to work?
Thanks in advance
Nils
[Updated on: Tue, 21 February 2017 07:43] Report message to a moderator
|
|
|
Re: [neon] is there a new way of setting "checked"-status for table rows in neon? [message #1754604 is a reply to message #1754410] |
Mon, 20 February 2017 19:50 |
|
Nils,
Here is an example showing two ways to correctly add a row and check it at the same time:
@Order(10)
public class SimpleTableField extends AbstractTableField<SimpleTableField.Table> {
@Override
protected int getConfiguredGridH() {
return 10;
}
public class Table extends AbstractTable {
@Override
protected boolean getConfiguredCheckable() {
return true;
}
public TestColumn getTestColumn() {
return getColumnSet().getColumnByClass(TestColumn.class);
}
@Order(10)
public class TestColumn extends AbstractStringColumn {
@Override
protected String getConfiguredHeaderText() {
return "Test";
}
}
}
}
@Order(10)
public class InsertAndCheckMenu extends AbstractMenu {
@Override
protected String getConfiguredText() {
return "Insert and check";
}
@Override
protected void execAction() {
SimpleTableField.Table table = getFieldByClass(SimpleTableField.class).getTable();
// This will work
ITableRow row = table.addRow();
table.getTestColumn().setValue(row, "[1] The date is: " + new Date());
table.checkRow(row, true); // or row.setChecked(true);
// This will not work...
ITableRow row2 = table.createRow();
table.getTestColumn().setValue(row2, "[2] The date is: " + new Date());
row2.setChecked(true);
// ...but now it does
ITableRow row3 = table.addRow(row2);
row3.setChecked(true);
}
}
I'm not quite sure why the "row2" case does not work, but apparently, the checked flag is not considered when a "normal" table row is added to the table (and thus converted to an "internal" table row). I think you have hit a small bug. If we find the time, we will look into this issue. Thanks for bringing it to our attention.
I hope in the mean time, you can work around this problem using one of the above approaches.
Regards,
Beat
|
|
|
|
Powered by
FUDForum. Page generated in 0.03497 seconds