开发者

How to persist/store values at runtime

开发者 https://www.devze.com 2023-01-17 17:41 出处:网络
I have a scenario which is as follows:- A form containing 2 grids. The grid on the left contains a list of groups. When a group is selected the grid on the right populates with another list with chec

I have a scenario which is as follows:-

A form containing 2 grids. The grid on the left contains a list of groups. When a group is selected the grid on the right populates with another list with check boxes.

I would like to be able to select group A and select some random check boxes and then switch to group B and select some other check boxes. However when I select group A again I would like to be able to restore the previously selected check boxes.

This would allow me to preload the settings from the database and also update the changes in one go rather than expecting the user to select apply after the changes for each group.

I'm开发者_开发技巧 unsure of the best way to approach this problem. Any feedback is appreciated.

Thanks

Sean.


I've done something like this using DataTables and DataViews to implement client-side filtering. You have a dataTable with the tickboxes that contains all groups of data. Then when you click grid 1, you update the DataSOurce of the grid to a new DataView(DataTable,"GroupID=1") ,"",CurrentRows) (i.e. Sets the filter proprety of the DataView to filter on the selected group THen when you're done, the DataTable has all the tick boxes you just saev the DataTable to the database.

Hope that makes sense.


I'd start with coming up with a database table to store your data - let's say MyTable(UserId, GroupId, ItemId, Selected). When the app starts I'd read the data from the table based on the UserId. I'd process this data into a couple of collections that I could associated with the grids - one having unique groups, the other items associated with a group and the selection status. Set up some event handlers to keep the collections in sync with the user input. Implement some save routine upon hitting a button or form closing and you should be good !

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号