谁能告诉我哪种数据结构代表了Javascript.Help中的以下场景。我正在寻找不同的选项,如树遍历,双向链表,但需要更好的输入。
用例:来自服务器的对象表示如下所示
behaviour Id 1 [checkbox]
Combinable is [2,3]
Behaviour 2 [checkbox]
combinable is [8]
Behaviour 3 [checkbox]
combinable is [5]
Behaviour 4 [checkbox]
combinable is [7]
Behaviour 5 [checkbox]
combinable is []
Behaviour 6 [checkbox]
combinable is []
Behaviour 7 [checkbox]
combinable is []
Behaviour 8 [checkbox]
combinable is [9]
Behaviour 9 [checkbox]
combinable is []考虑到下面的场景,我需要双向遍历。
用例1:当用户选择行为id 1,1,2,8,9和1,3,5时,复选框的enabled.Rest将被禁用。
用例2:这是双向的。继续使用用例1,当用户选择8并取消选择id 1时,则应启用8,9,但应禁用1,2,3,4,5,6。
我编辑了这个问题,以确保它更具understandable..thanks。
发布于 2014-06-24 00:54:10
为什么不使用json结构来存储关系呢?
var relationship = {
1 : {
2,3
},
2 : {
4
},
3 : {
5,6
},
4 : {
6,7
}
}因此,将行为id与关系对象中的键绑定。迭代并勾选相应的值。
https://stackoverflow.com/questions/24371163
复制相似问题