how to remember selection from Table Widget
Question
Application Type
Reactive

HI,

I bound my Entity Records to my Table Widget, applied paging to it and it also consists Checkbox.  I have Delete Button top of the Table Widget to delete the checked records / rows.

Problem:

If select 1 record / or multiple records from Page1 and another from Page 2 [From Paging] and when I come back from Page 2 to Page 1 or Page 1 to Page 2  again then it untick my previous selection. It does not remember it. 

How to solve this issue?

I hope i properly explained it.


Thanks


Here you have your solution! SO what I did was:

1.When the checkbox changed, I did a list append of that record to a local variable called:

CheckboxRecordsSelected

2.Your problem is, the pagination keeps refreshing your table, so all of the selected keeps coming back to the previous state, or the state that is on the original table. So what I did was, on the aggregated, I used, I created a client action on after fetch...

3. And every time i do the after fetch I go to my local variable that has the list of records that I selected and wanted to save/memorize and I keep updating the Aggregate with the things that I memorize

Now, the table is remembering and when you click on the Update All it saves everything that was selected/remembered. :)

PS: you can also use this to update something or delete something, you just have to change on the server action that i created, from CreateOrUpdate to delete action

Best Regards,

Márcio C.



CheckboxChanges.oml

Thanks Marcio.

Now I got some idea about it's usage now. 


Yes! You will figure out, and I hope this demonstration makes you grow in terms of these logical things in OutSystems :)

Keep up with the good work and effort.

Regards,

Márcio C.

Hello @NathanAstel 

So if you are working on the checkbox, you need to have on your entity the property boolean to that checkbox, if you want to keep the checkbox selected even when you change the pagination, you have 2 options, or you keep saving the state of the checkbox to the entity, or you keep saving it to a local variable as list and saving those checkboxes that were selected. I will share one of the solutions.

Regards,

Márcio C.

CheckboxChanges.oml

If you want to select all the records you want to delete, and they are between pages, you need to use a local variable type list, and every time you change one checkbox, you need to add to the list that record, and when you click on the button delete, you do a for each and delete using all the ids of each record. :) I can see one solution to you if this is the problem.

Hi Marcio,

Thanks for your reply and sharing oml. I understand your oml but can you also explain how do I store it in local variable?

And How to store multiple checked into that local variable. Means sorry i have not complete idea. But it should like below 

localVar[0] = true

localVar[3] = true


localVar[15] = true


Like that. I am not sure how to achieve this approach. Please guide me here.

Very Thanks


Yes, that's correct! I will work on a solution, but that's the logic.

regards,

Márcio C.

Here you have your solution! SO what I did was:

1.When the checkbox changed, I did a list append of that record to a local variable called:

CheckboxRecordsSelected

2.Your problem is, the pagination keeps refreshing your table, so all of the selected keeps coming back to the previous state, or the state that is on the original table. So what I did was, on the aggregated, I used, I created a client action on after fetch...

3. And every time i do the after fetch I go to my local variable that has the list of records that I selected and wanted to save/memorize and I keep updating the Aggregate with the things that I memorize

Now, the table is remembering and when you click on the Update All it saves everything that was selected/remembered. :)

PS: you can also use this to update something or delete something, you just have to change on the server action that i created, from CreateOrUpdate to delete action

Best Regards,

Márcio C.



CheckboxChanges.oml

Thanks Marcio.

Now I got some idea about it's usage now. 


Yes! You will figure out, and I hope this demonstration makes you grow in terms of these logical things in OutSystems :)

Keep up with the good work and effort.

Regards,

Márcio C.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.