How to represent this data structure in Javascript -



How to represent this data structure in Javascript -

can help me datastructure represents next scenario in javascript.help appreciated. looking @ different options tree traversal ,doubly linked list need improve inputs.

use case : object representation comes server follows

behaviour id 1 [checkbox] combinable [2,3] behaviour 2 [checkbox] combinable [8] behaviour 3 [checkbox] combinable [5] behaviour 4 [checkbox] combinable [7] behaviour 5 [checkbox] combinable [] behaviour 6 [checkbox] combinable [] behaviour 7 [checkbox] combinable [] behaviour 8 [checkbox] combinable [9] behaviour 9 [checkbox] combinable []

considering next scenario, need traverse bi-directional.

use case 1 : when user selects behaviour id 1, [1,2,8,9] , [1,3,5] should enabled.rest of checkboxes disabled.

use case 2 : bi-directional. in continuation utilize case 1, when user selects 8 , deselects id 1, then[8,9] should enabled [1,2,3,4,5,6] should disabled.

i edited question create sure more understandable..thanks.

why not have json construction store relationship ?

var relationship = { 1 : { 2,3 }, 2 : { 4 }, 3 : { 5,6 }, 4 : { 6,7 } }

so bind behavior id key in relationship object. iterate , tick corresponding values.

javascript data-structures

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -