I have a table populated with records from an entity i created. For each row on the table, there is a checkbox. When you click that checkbox, you select/deselect that same record from the table in order to enable or disable certain buttons. The table in question also has pagination. When i select a record from one of the pages, switch to another page then come back, the record i previously selected has been deselected. How can i maintain the selected record?

Hi bpal98,


by 'table' I assume you mean a Table Records Widget ?  And by 'pagination' I assume you mean the List Navigation Web Block ?

So every time you go to another page, you are doing a refresh of the aggregate that is the source of your Table Record, and an Ajax refresh of your Table Records.  At that point you overwrite anything that was already in the Table Records.  So it makes perfect sense that you also loose previous selections done for records in your table.

How long do you want to maintain the selections ?  I assume multiple records can be either selected or deselected ?  Can each user have different selections on or off (i.e. is it some sort of user preference to have some of them on and others not, or should a selection done by one user also affect another).  Do your users expect the selection to still be there after paging back an forth ?  So would they also expect their previous choices to still be there after leaving the app and coming back to it ?  

Depending on the answers to this type of questions, you can choose to somehow make the selections more or less permanent (i.e. store in the database) before moving away from a page.


Hope this helps,

Dorine

Hi,


You can do something I tried on table record with pagination which has checkbox related to it.


How you can do it is explained below:


  1. Put an on change screen action on the checkbox.
  2. In the action just loop through the list of table records.
  3. If you find a checkbox checked then put an assign to it and just add a true flag to that record and vise a versa.


Hope the above explanation helps. If you can't understand the process please share the oml file.


Regards,

Manthan Shah.



Also, forgot to mention that the attribute that i used to populate the checkbox variable is an extra attribute in the table's aggregate set as a boolean instead of an actual attribute from the entity in question.

I just figured it out: since i had a variable which stored the id of the selected record, all i had to do was set an "if" condition in that extra boolean attribute i mentioned to determine if the id of that record is equal to the selected one.