List Navigation - Persist select state across different pages

List Navigation - Persist select state across different pages

  

I am developing a Web application where I am using a List_Navigation to traverse across different pages in the list. Each list item has a checkbox at the end for selecting the row.

I want to be able to maintain the selection of the rows across the pages. i.e., if the user selects a row in page 1 and traverse to page 5 selects few rows and when he navigates back to page 1, he should still see the check mark for the row he selected.  I want to maintain the selected state across the different pages

Note: I wan to maintain the state in the client side, do not want to store it in session

Any guidance for implementing this feature will be very helpful.




Solution

Hi Raj,

To do that you have to store the information about the checkboxes somewhere and not on the aggregate or table since both will be refeshed when you navigate the pages of the table. 

One solution is to use a hashtable where you store the ids of the items selected. Then, when you refresh the aggregate, you use that hashtable to set the checkboxes according to the values that you set in it.

Check a possible solution in the oml attached. In there I'm using the TextDictionary to do that.

Cheers,

José

Solution

José Costa wrote:

Hi Raj,

To do that you have to store the information about the checkboxes somewhere and not on the aggregate or table since both will be refeshed when you navigate the pages of the table. 

One solution is to use a hashtable where you store the ids of the items selected. Then, when you refresh the aggregate, you use that hashtable to set the checkboxes according to the values that you set in it.

Check a possible solution in the oml attached. In there I'm using the TextDictionary to do that.

Cheers,

José

Hi Jose,

That was a great solution you had provided thank you so much, that would solve my problem. Just a add on question, in the solution which you had provided, there is a hit to the server every time you click the checkbox, and the logic to persist the selected state runs on the server, is there any way if we could handle the entire functionality in the client side. i.e., clicking the checkbox should not hit the server. I am thinking why should this logic be executed on a server, it is an additional load to the server, could this be executed in client side using scripts. Is it possible to add or remove items to the TextDictionary using JavaScript?

Regards,

Raj