How to handle a TableField efficiently? [message #1783259] |
Fri, 09 March 2018 22:01  |
|
Scout: 6.0.200
Eclipse for Scout Developers:
Version: Oxygen.2 Release (4.7.2)
Build id: 20171218-0600
<< see image >>
Use case:
I would like to record the persons from a party (person table is in database available // Mapping table between persons and party is in the database available)
Description of the previous implementation:
I have a party form (A). In this form there are different elements (title, begin, etc.). Likewise a ParticipantsTableField (B) - with the columns "Firstname", "Lastname", "Mail", etc.
If I want to add a new person to the ParticipantsTableField (NewPersonMenu), an AddPersonForm (C) will be opened with a smartfield "PersonLookupCall". This field (PersonLookupCall) is also a master field for other invisible fields - just these additional fields like "Firstname", "Lastname", "Mail", etc.
The action of the NewPersonMenu is checked for an "if - isFormStored ()". If this is true, I create a new line in ParticipantsTableField (createRow) and set this to "Inserted" (setStatusInserted ()).
if (personForm.isFormStored()) {
Table table = getTable();
ITableRow r;
r = table.addRow(getTable().createRow());
table.getParticipantsIDColumn().setValue(r, UUID.randomUUID().toString());
table.getPersonIDColumn().setValue(r, personForm.getPersonSmartField().getValue());
table.getFirstNameColumn().setValue(r, personForm.getFirstNameField().getDisplayText());
table.getLastNameColumn().setValue(r, personForm.getLastnameField().getDisplayText());
table.getEmailColumn().setValue(r, personForm.getEmailField().getDisplayText());
r.setStatusInserted();
}
Everything works great! Now to my two questions:
- State of the art
Is that "state of the art" <or> can I improve? If yes how?
- Peoplegroup
Since often the same people come to a party, there is also a "group of people". Adopted in group "BSI-Core" are 10 persons. These should then be added to the table "ParticipantsTableField" when selecting this group (new menu in the ParticipantsTableField: AddPersonGroup). For this I can not use the AddPersonForm (C) - because there is only one person with hidden single fields and therefore not more people can be selected.
* How can I select a group of people and then access the database in the ParticipantsTableField menu?
* Or am I mentally in the wrong place?
Cheers and many Thanks
|
|
|
Re: How to handle a TableField efficiently? [message #1783436 is a reply to message #1783259] |
Tue, 13 March 2018 07:29   |
Eclipse User |
|
|
|
Your solution looks quite good and resembles the "Event-Form" of the Demo application, so you can consider it close to state of the art :)
Two notes:
You can add a new row more compact: table.addRow(). Since the default implementation will set the row state to inserted, you can remove the last line in your snippet.
Since you already have a smartfield with a lookup call for the person in your "chooser form", you could use the "editable column" feature. Instead of opening a form to choose the person, the user could add rows to the table and edit it inline. As long as it is a AbstractSmartColumn with the lookup call set, it will create the proposal list you're used from smartfields. Check out "getConfiguredEditable" and "getConfiguredMandatory" on the columns. (For reference, check out the widgets demo app).
This could also make your "add people group" functionality easier.
The disadvantage of this solution is that if combined with a smartfield, you have to restrict yourself to a single column, or load the values of additional "display-only" columns manually.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03279 seconds