0

I display hierarchical data in my AdvancedDatagrid. I have set a checkbox as itemrenderer for the column which displays the hierarchical .Each leaf node in the view has checkbox next to it. Suppose group A node has A1, A2, A3 etc as child nodes and group B has B1, B2 etc as child nodes. All child nodes ie leaf nodes will have checkbox next to it. If I select any of the check box under group A automatically the checkboxes under other groups should be disabled and on uncheck of checkbox it should enable.

Please let me know as how to achieve it.

1 Answers1

0

The absolute best way to do this is create your hierarchical tree in your data model. So for every node that has children, if you have a selected property, you would also modify the selected property on those children. This way, your ADG is merely a view of the state of the data. You then tie the change event of the checkbox to this selected property.

[Edit to show Tree sample]

So similar to XML, you're data structures can have a tree leaf/node paradigm For Example (psuedo code):

A tree of "People":

var gf:Person = new Person();
    gf.name = 'Frank';

var gm:Person = new Person();
    gm.name = 'Elise';

var c1:Person = new Person();
    c1.name = 'Mary';

var c2:Person = new Person();
    c2.name = 'Frank Jr';

var c3:Person = new Person();
    c3.name = 'Sam';

var couple:PersonGroup = new PersonGroup();
    couple.relation = [gm, gf];
    couple.children = [c1, c2, c3];

//now you add another 'married PersonGroup to child one, and their children'

So since you have a 'children' property the HierarchicalData knows how to work with this, but their is a field which allows you to set it to something else if your 'node' is named something else.

So to extend this each 'Person' would have a property that is 'selected, enabled, alive, whichever', and that property needs to be a setter, which then modifies that property also present in it's children. In this way the state of your data is always preserved in your data model, and the ADG just happens to be the current view that you use to display that representation.

Mike Petty
  • 949
  • 6
  • 6
  • How to get the parent node of selected item in hierarchical data – FlexCoder27 Nov 20 '12 at 10:10
  • You need the getParent method of HierarchicalCollectionView http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/collections/HierarchicalCollectionView.html#getParentItem() – flexicious.com Nov 28 '12 at 20:54