5 Replies Latest reply on Mar 21, 2007 5:31 AM by ichabodBcrane

    Dynamic Drill Down

    ichabodBcrane
      I am really new with Flex so this may be an easy one. I have 6 containers opening up. The first contains a Tree drill down pulled from XML. I need to be able to have those clickable (which they are):

      <mx:XMLList id="treeData">
      <node label="Districts">
      <node label="Dist1">
      <node label="test1 "/>
      <node label="test2"/>
      </node>
      <node label="Dist2">
      <node label="test1 A" />

      <node label="Test 2 a "/>
      </node>
      </node>

      </mx:XMLList>


      <mx:Tree id="myTree" width="100%" height="100%" labelField="@label"
      showRoot="false" dataProvider="{treeData}" change="treeChanged(event)"/>


      When I click those I need to be able to populate the next container with a list (coming from seperate XML) of clickable items. This is going to be repeated until I reach the final container with an answer.

      Any ideas? Im sure this is already out there in some fashion.

      Thanks

        • 1. Re: Dynamic Drill Down
          ntsiii Level 3
          Can't point to a full example.

          But have a change handler on each control filter the dataprovider for the next control.

          Tracy
          • 2. Dynamic Drill Down
            ichabodBcrane Level 1
            Thanks Tracy...

            So I have gotten this far... what I need to do is to make this action work with list style items.

            Essentially when you select a "County" it will refresh District, school and Curr.
            Then if you select a county, it will refresh down the line again.

            I have this functioning with ComboBox but I need them to work as lists but it gives me big fat errors when I change it over...

            Any ideas?

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initVars()">



            <mx:Script>
            <![CDATA[
            import mx.collections.XMLListCollection;
            import mx.controls.Alert;


            [Bindable]
            private var dists:XML ;

            private var countyList:XMLList;

            [Bindable]
            private var countyListCol:XMLListCollection;


            private var schoolNameList:XMLList ;

            [Bindable]
            private var schoolNameListCol:XMLListCollection ;

            private var trimList:XMLList;

            [Bindable]
            private var trimListCol:XMLListCollection;

            private var curriculumList:XMLList;

            [Bindable]
            private var curriculumListCol:XMLListCollection;

            private function initVars():void {


            dists =
            <dists>
            <county myCounty='County1'>
            <model name='Dist1'>
            <trim name='School1'>
            <curriculum name='Curriculum 1'></curriculum>
            <curriculum name='Curriculum 2'></curriculum>
            <curriculum name='Curriculum 3'></curriculum>
            </trim>
            </model>
            <model name='Dist2'>
            <trim name='School2'>
            <curriculum name='Curriculum 4'></curriculum>
            <curriculum name='Curriculum 5'></curriculum>
            </trim>
            <trim name='School3'>
            <curriculum name='Curriculum 6'></curriculum>
            </trim>
            </model>
            </county>
            <county myCounty='County2'>
            <model name='Dist3'>
            <trim name='School 1'>
            <curriculum name='Curriculum 7'></curriculum>
            <curriculum name='Curriculum 8'></curriculum>
            <curriculum name='Curriculum 9'></curriculum>
            </trim>
            <trim name='School 2'>
            <curriculum name='Curriculum 10'></curriculum>
            </trim>
            </model>
            <model name='Dist4'>
            <trim name='School 3'>
            <curriculum name='Curriculum 11'></curriculum>
            <curriculum name='Curriculum 12'></curriculum>
            </trim>
            <trim name='School 4'>
            <curriculum name='Curriculum 13'></curriculum>
            <curriculum name='Curriculum 14'></curriculum>
            <curriculum name='Curriculum 15'></curriculum>
            </trim>
            </model>
            <model name='Dist5'>
            <trim name='School 5'>
            <curriculum name='Curriculum 16'></curriculum>
            </trim>
            <trim name='School 6'>
            <curriculum name='Curriculum 17'></curriculum>
            </trim>
            </model>
            </county>
            <county myCounty='County3'>
            <model name='Dist6'>
            <trim name='School 7'>
            <curriculum name='Curriculum 18'></curriculum>
            </trim>
            <trim name='School 8'>
            <curriculum name='Curriculum 19'></curriculum>
            </trim>
            <trim name='School 9'>
            <curriculum name='Curriculum 20'></curriculum>
            </trim>
            <trim name='School 10'>
            <curriculum name='Curriculum 21'></curriculum>
            </trim>
            </model>
            <model name='Dist7'>
            <trim name='School 11'>
            <curriculum name='Curriculum 22'></curriculum>
            </trim>
            <trim name='School 12'>
            <curriculum name='Curriculum 23'></curriculum>
            </trim>
            </model>
            </county>
            </dists>;

            countyList = dists.county.@myCounty;

            countyListCol = new XMLListCollection(countyList);

            schoolNameList = dists.county[0].model.@name;

            schoolNameListCol = new XMLListCollection(schoolNameList);

            trimList = dists.county[0].model[0].trim.@name;

            trimListCol = new XMLListCollection(trimList);


            curriculumList = dists.county[0].model[0].trim[0].curriculum.@name;

            curriculumListCol = new XMLListCollection(curriculumList);

            }





            private function refreshcountyNames():void {



            schoolNameList = dists.county.(@myCounty == myCountyNames.selectedLabel).model.@name;

            schoolNameListCol = new XMLListCollection(schoolNameList);

            trimList = dists.county.(@myCounty == myCountyNames.selectedLabel).model[0].trim.@name ;

            trimListCol = new XMLListCollection(trimList);

            curriculumList = dists.county.(@myCounty == myCountyNames.selectedLabel).model[0].trim[0].curriculum.@name;

            curriculumListCol = new XMLListCollection(curriculumList);

            }



            private function refreshTrim():void {


            trimList = dists.county.model.(@name == countyNames.selectedLabel).trim.@name;

            trimListCol = new XMLListCollection(trimList);

            curriculumList = dists.county.model.(@name == countyNames.selectedLabel).trim[0].curriculum.@name;

            curriculumListCol = new XMLListCollection(curriculumList);



            }


            private function refreshCurriculum():void {


            curriculumList = dists.county.model.trim.(@name == trimNames.selectedLabel).curriculum.@name;

            curriculumListCol = new XMLListCollection(curriculumList);


            }

            ]]>
            </mx:Script>



            <mx:Panel width="80%" height="80%">

            <mx:HBox>
            <mx:Label text="County" />

            <mx:ComboBox id="myCountyNames" dataProvider="{countyListCol}" change="refreshcountyNames()" />

            <mx:Spacer width="20" />

            <mx:Label text="District" />
            <mx:List id="countyNames" dataProvider="{schoolNameListCol}" mouseDown="refreshTrim()"/>
            <!-- <mx:ComboBox id="countyNames" dataProvider="{schoolNameListCol}" change="refreshTrim()"/> -->

            <mx:Spacer width="20" />

            <mx:Label text="Schools" />
            <mx:ComboBox id="trimNames" dataProvider="{trimListCol}" change="refreshCurriculum()"/>

            <mx:Spacer width="20" />

            <mx:Label text="Curriculum" />
            <mx:ComboBox id="curriculumNames" dataProvider="{curriculumListCol}"/>

            </mx:HBox>

            </mx:Panel>

            </mx:Application>

            Thanks

            B
            • 3. Re: Dynamic Drill Down
              ntsiii Level 3
              What do you mean by "... to work as lists ..."?
              And by "... big fat errors "?
              And by "...change it over"?
              Tracy
              • 4. Re: Dynamic Drill Down
                ichabodBcrane Level 1
                Sorry.. I should have been a little more descriptive.

                I have this functioning with <mx:ComboBox right now. I need to get rid of the combobox and put in Mmx:list to replicate the same functionality as I am getting with the combo. I can't put the error in as I dont have flex on this computer I am on right now. But it is a 1069 error.. something in regards to there not being a default value.

                Thanks
                • 5. Re: Dynamic Drill Down
                  ichabodBcrane Level 1
                  The error I get when I change the first ComboBox to a List is the following when I select one of the options:

                  ReferenceError: Error #1069: Property selectedLabel not found on mx.controls.List and there is no default value.
                  at xmlTest/::refreshcountyNames()
                  at xmlTest/__myCountyNames_mouseUp()