Adding rows to tablefield [message #932074] |
Wed, 03 October 2012 16:14  |
Eclipse User |
|
|
|
Hi,
I need to add rows to a table field, the posible items for the rows are in a table in the database and it must be easy to find what you are looking to insert. Whats the best way to accomplish this?
There is a form and search form already for the database table. Should i create a special form and call it when the user whants to add something?, or there is a way to reuse the searchform in some way?
thanks in advance
sebastian
|
|
|
|
|
|
Re: Adding rows to tablefield [message #933645 is a reply to message #933489] |
Fri, 05 October 2012 03:48   |
Eclipse User |
|
|
|
Sebastian Boccardi wrote on Fri, 05 October 2012 05:53The thing is that after the user selected an item, the drop-down disappears and the item appears in the cell, but when you click another cell o press tab or add a new row the item disappears from the cell.
I don't know why.....
At the end of Edition, you need to handle what should occurs with execCompleteEdit. In your case, you probably want to assign the selected value of the smartfiled, as value of the row (for this column).
Here a simple example:
@Order(20.0)
public class StyleColumn extends AbstractSmartColumn<Long> {
@Override
protected String getConfiguredHeaderText() {
return ScoutTexts.get("Style");
}
@Override
protected Class<? extends ICodeType> getConfiguredCodeType() {
return StyleCodeType.class;
}
@Override
protected boolean getConfiguredEditable() {
return true;
}
@Override
protected void execCompleteEdit(ITableRow row, IFormField editingField) throws ProcessingException {
setValue(row, ((ILongField) editingField).getValue());
}
}
We should document editable column, on the Column page in the wiki.
|
|
|
|
|
Re: Adding rows to tablefield [message #936714 is a reply to message #934501] |
Mon, 08 October 2012 05:00  |
Eclipse User |
|
|
|
Sorry for the wrong class.
"ISmartField<Long>" produces a warning, because at runtime it is not possible to verify that the value is a Long... You can suppress the warning with a SuppressWarnings ("unchecked"), to indicate to the compiler that you are sure that you will get a Long.
==> See What is SuppressWarnings ("unchecked") in Java?
If you do not like having a SuppressWarning, the best you can do is to cast editingField to "ISmartField<?>" instead of "ISmartField<Long>".
But in this case, the value is an Object. So you need to cast this value to a long.
@Override
protected void execCompleteEdit(ITableRow row, IFormField editingField) throws ProcessingException {
Object value ((ISmartField<?>) editingField).getValue();
setValue(row, (Long) value);
}
I am not sure which pattern is better.
.
|
|
|
Powered by
FUDForum. Page generated in 0.19223 seconds