Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Some questions on hierarchical editable TablePage(Regarding saving to database and loading the table)
Some questions on hierarchical editable TablePage [message #1797691] Mon, 05 November 2018 09:17 Go to next message
The Maddes is currently offline The MaddesFriend
Messages: 44
Registered: October 2018
Member
Hello,

it's me again.

Thanks to Patrick i managed to make progress in my application and build a lot of tables, forms etc.
Now i came to a point where i cannot find any solution and would highly appreciate some advice from the pros :)

1. I have a HIerarchical Tablepage which is called from an TabBox.
The page gets rendered nice and the hierarchy is working as expected, all data is coming from the database.
Now what i want to achieve is:
I want to have an empty row under each parentrow, if there are children or not.
This row should represent a child which might or might not be edited and saved to the database afterwards.
How can one achieve this?

2. This leads me to the second question. This hierarchical table should have all children rows with some editable fields in the table. I just didnt find a documentaion on how to save changes made in an editable table. I think there needs to be some kind of listener that queues up the changes of each row and then sends it to the service to update/insert those changes. Is there anything out of the box or what would be the best way to do this?

I'm sorry if my questions might have been answered already, but i didn't find a working solution for my case.

Thank you in advance!


EDIT:
Maybe it is best if i tell you what my goal is.
I want to have some kind of timemanagement where each day is represented in a tab, and each tab has a tablepage showing the informations for that day in which the user can enter/edit data for that specific time. So maybe its easier to eventually see it as a whole.

[Updated on: Mon, 05 November 2018 10:53]

Report message to a moderator

Re: Some questions on hierarchical editable TablePage [message #1797853 is a reply to message #1797691] Wed, 07 November 2018 13:18 Go to previous messageGo to next message
The Maddes is currently offline The MaddesFriend
Messages: 44
Registered: October 2018
Member
So i managed to get some information so far.

At the moment i added sth like this to the editable column:

@Override
protected void execCompleteEdit(ITableRow row, IFormField editingField) {

	BigDecimal oldValue = getValue(row);
	BigDecimal newValue = ((IValueField<BigDecimal>) editingField).getValue();
				
	Integer entryId = getIdColumn().getValue(row);

	if(oldValue.compareTo(newValue) != 0) {
		System.out.println( "ID " + entryId + " updated");				
		super.execCompleteEdit(row, editingField);
	} else {}	
}


But still i dont know if this is the right way and i dont see how i can tell the table to save that information in the database. Any help is really appreciated
Re: Some questions on hierarchical editable TablePage [message #1797957 is a reply to message #1797853] Fri, 09 November 2018 08:52 Go to previous messageGo to next message
Patrick Baenziger is currently offline Patrick BaenzigerFriend
Messages: 96
Registered: September 2011
Member
Hi there

It depends a bit on where your table is located and what your desired outcome is, especially when the changes in the table should be saved.

Let's assume that your editable table is located in a form with a "Save" Button. When adding, editing and removing rows in a table, Scout updates the status of the row ( ITableRow.getStatus() ; See ITableRow for all status codes).
Scout also does not really remove rows by default, it just marks them as deleted - which allows you to also handle these later. (Note: The "Discard" function on the other hand will remove the deleted rows immediately).

Now, if you wish to store changes that you made in your editable table when the user clicks "OK" to close the form and you are using the standard pattern of using exportFormData(...), you can loop over all rows in the service where you process the save action.
Using the status, you can detect what the user did with the row and add, alter or remove the corresponding rows in the database.
(You can see a possible implementation - without editable rows - in the events demo app: FormCode and backend code and the online demo (choose "events")

Regarding your request for "empty rows" - you can handle this either on the client or server side and insert the appropriate rows where desired.
Note: On Import of a FormData, all row states are set to "STATUS_NON_CHANGED".

A typical implementation either uses a "add row" context menu to let the user manually add a row at or listens to table changes to ensure there is at least one empty row to fill.
Personally, I recommend the first one - it's simple and reliable. The second one tends to be harder to implement and more error-prone.


Does this about cover your question or did you have something else in mind with your design?
Re: Some questions on hierarchical editable TablePage [message #1797961 is a reply to message #1797957] Fri, 09 November 2018 09:22 Go to previous messageGo to next message
The Maddes is currently offline The MaddesFriend
Messages: 44
Registered: October 2018
Member
Hi Patrick,

thanks for your response. I think thats some good information you provided here.
I will try to implement it in that way, and i think the main difference in your example, that you use a table inside of the form, which makes it a lot easier to access everything.
I had tab box which extended
AbstractPageField<MyTablePage>
and then called setPage in the execInitField method
I think that was the first step giving me a hard time.

I will try to implement in one Box with a tablefield like you suggested for the moment.

For the row insertion i will need to take both ways, because its crucial to have the table rendered with an empty row for each parent of the hierarchy and the user has to be able to add a new row manually.
But i think with your input i will be able to handle this.

I know i might ask weird questions, but the problems i face are mostly when it comes to dynamic creation and handling of situations. I think thats where i lack a deeper understanding of how Scout handles those things.
I will let you know if i managed to make it and thank you again for your advice!

[Updated on: Fri, 09 November 2018 10:18]

Report message to a moderator

Re: Some questions on hierarchical editable TablePage [message #1797985 is a reply to message #1797961] Fri, 09 November 2018 14:25 Go to previous messageGo to next message
The Maddes is currently offline The MaddesFriend
Messages: 44
Registered: October 2018
Member
So to leave something here over the weekend if someone has an idea pls let me know :)

Ill outline what i try to achieve, but i get stuck pretty much (maybe because of my design thoughts) mostly on how to achieve dynamic stuff happening.

What i want to do is:
Have a dynamic outline which creates and entry for each year from 2018.
Each year should have childpages of each month.
If i click on an outline of a month, i want to render tabboxes for each day of the month, these tabboxes should not be closable.
Each tabbox should have a table showing hierarchical todos depending on the data from the database. Each hierarchical parent should have an empty todo from the start.
If i edit an empty todo and/or add new child todos for individual parent todos, i need to be able to save them to the database.

I thought the ideal design would be a tablepage which has editable columns as needed. But i only found a way on overriding the pageDeactivated method to save changes to a tablepage.

So far my journey on this approach.

Maybe someone with more experience has a more ideal design approach for that case or an idea how to make my approach happening in Scout.

Have a nice weekend!
Re: Some questions on hierarchical editable TablePage [message #1798070 is a reply to message #1797985] Mon, 12 November 2018 08:13 Go to previous message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 202
Registered: November 2010
Senior Member
The Maddes wrote on Fri, 09 November 2018 09:25
What i want to do is:
Have a dynamic outline which creates and entry for each year from 2018.
Each year should have childpages of each month.
If i click on an outline of a month, i want to render tabboxes for each day of the month, these tabboxes should not be closable.


You can use node pages or table pages for your year / month data. With node pages you generate your dynamic nodes in execCreateChildPages(), with table pages you create the data in execLoadData(). For your use case, table pages are probably the better alternative. They are more flexible and allow multiple columns (e.g. you could display the months total).

The "month" page should be marked as "leaf" and provide a detail form. This form then contains your tab boxes with table fields etc. You can also consider using only one table and switch the day using buttons, a text field or a smart field.

Quote:
I thought the ideal design would be a tablepage which has editable columns as needed. But i only found a way on overriding the pageDeactivated method to save changes to a tablepage.


You can handle changes in editable cells by overriding the method execCompleteEdit() on the corresponding column. You should probably store every change at once. As you have notices, table pages not really have a life-cycle, they just "exist". So when you are holding non-persisted data in them, you need listeners for all events that cause the page to be removed (can happen if you go up one level and "refresh" the list). Or you add an explicit save button and leave it to the user to press it...

For practical reasons we recommend using forms to collect and store data. They require one more user action to start, but they have a proper life-cycle and are therefore much clearer to use.

Regards,
Beat
Previous Topic:Table Menubar at top
Next Topic:Multisession login
Goto Forum:
  


Current Time: Fri Mar 29 01:04:04 GMT 2024

Powered by FUDForum. Page generated in 0.04881 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top