1 Reply Latest reply on Apr 24, 2007 7:17 AM by Unclebensrice

    Get selectedItem from Datagrid inside a TabNavigator

    Unclebensrice
      I am trying to display information from a datagrid, however the datagrid is not at the top level of xml its within a TabNavigator, the usual "mydatagrid.currentItem.whatever" displays the data however drilling down any further is not working for me.

      Any help on this would be much appreciated
      example code below:

      MXML
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:v="views.*" xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="basic1.send();basic2.send()" >

      <mx:HTTPService url="assets/data/Basic1.xml" id="basic1"/>
      <mx:HTTPService url="assets/data/Basic2.xml" id="basic2"/>
      <mx:Panel width="100%" height="100%" title="Match ID Test" id="pnl1">
      <mx:TabNavigator right="0" bottom="0" top="0" left="0" id="subNav" width="100%" height="100%">
      <mx:Repeater dataProvider="{basic1.lastResult.Root.Item}" id="rep3">
      <mx:Canvas label="{rep3.currentItem.name}">
      <mx:VBox width="100%" height="100%" id="v1">
      <mx:Repeater dataProvider="{basic2.lastResult.Root.Item}" id="blah2">
      <mx:Text color="green" id="fred" text="{blah2.currentItem.help.id}" visible="{blah2.currentItem.ID==rep3.currentItem.ID}" includeInLayout="{blah2.currentItem.ID==rep3.currentItem.ID}" />
      <mx:DataGrid selectedIndex="0" id="Grids" dataProvider="{blah2.currentItem.help.Row}" visible="{blah2.currentItem.ID==rep3.currentItem.ID}" includeInLayout="{blah2.currentItem.ID==rep3.currentItem.ID}"/>
      <!--
      Here I would like to get the selected Item Title from "Grids" and display in a <mx:Text />.
      -->
      </mx:Repeater>
      </mx:VBox>
      </mx:Canvas>
      </mx:Repeater>
      </mx:TabNavigator>
      </mx:Panel>
      </mx:Application>

      XML File "Basic 1"
      <?xml version="1.0" encoding="UTF-8"?>
      <Root>
      <Item>
      <name>Tab 1</name>
      <ID>01</ID>
      </Item>
      <Item>
      <name>Tab 2</name>
      <ID>02</ID>
      </Item>
      <Item>
      <name>Tab 3</name>
      <ID>03</ID>
      </Item>
      </Root>
      XML File "Basic 2"
      <?xml version="1.0" encoding="UTF-8"?>
      <Root>
      <Item>
      <name>Tab 1</name>
      <ID>01</ID>
      <prov>Basic2</prov>
      <help id="Tab 1 Working">
      <Row>
      <Title>Panel 1 Item 1</Title>
      <description>My Description</description>
      <link>My Link</link>
      <pubDate>Mon, 10 Apr 2006 15:48:42 GMT</pubDate>
      </Row>
      <Row>
      <Title>Panel 1 Item 2</Title>
      <description>My Description</description>
      <link>My Link</link>
      <pubDate>Mon, 06 Mar 2006 15:48:42 GMT</pubDate>
      </Row>
      </help>
      </Item>
      <Item>
      <name>Tab 2</name>
      <ID>02</ID>
      <prov>Basic2</prov>
      <help id="Tab 2 Working">
      <Row>
      <Title>Panel 2 Item 1</Title>
      <description>My Description</description>
      <link>My Link</link>
      <pubDate>Mon, 24 May 2006 15:48:42 GMT</pubDate>
      </Row>
      <Row>
      <Title>Panel 2 Item 2</Title>
      <description>My Description</description>
      <link>My Link</link>
      <pubDate>Mon, 19 May 2006 15:48:42 GMT</pubDate>
      </Row>
      </help>
      </Item>
      <Item>
      <name>Tab 3</name>
      <ID>03</ID>
      <prov>Basic2</prov>
      <help id="Tab 3 Working">
      <Row>
      <Title>Panel 3 Item 1</Title>
      <description>My Description</description>
      <link>My Link</link>
      <pubDate>Mon, 06 Jul 2006 15:48:42 GMT</pubDate>
      </Row>
      <Row>
      <Title>Panel 3 Item 2</Title>
      <description>My Description</description>
      <link>My Link</link>
      <pubDate>Mon, 14 Jun 2006 15:48:42 GMT</pubDate>
      </Row>
      </help>
      </Item>
      </Root>
        • 1. Re: Get selectedItem from Datagrid inside a TabNavigator
          Unclebensrice Level 1
          Ok I have stripped this down a little more only using 1 XML file but still need to drill down further:

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

          <mx:HTTPService url="assets/data/Basic3.xml" id="basic2"/>
          <mx:Panel width="100%" height="100%" title="Match ID Test" id="pnl1">
          <mx:Text text="Attempt to match the ID tags from 2 XML sources and diaply data from Basic2"/>
          <mx:TabNavigator right="0" bottom="0" top="0" left="0" id="subNav" width="100%" height="100%">
          <mx:Repeater dataProvider="{basic2.lastResult.Root.Item}" id="rep3">
          <mx:Canvas label="{rep3.currentItem.name}">
          <mx:VBox width="100%" height="100%" id="v1">
          <mx:Repeater dataProvider="{rep3.currentItem.help}" id="blah2">
          <mx:Text color="green" id="fred" text="{blah2.currentItem.id}" />
          <mx:DataGrid selectedIndex="0" id="Grids" dataProvider="{blah2.currentItem.Row}" />
          <!-- This bit not working <mx:Text color="red" text="{Grids.selectedItem.Title}"/> -->
          </mx:Repeater>
          </mx:VBox>
          </mx:Canvas>
          </mx:Repeater>
          </mx:TabNavigator>
          </mx:Panel>
          </mx:Application>

          XML Basic 3
          <?xml version="1.0" encoding="UTF-8"?>
          <Root>
          <Item>
          <name>Tab 1</name>
          <ID>01</ID>
          <prov>Basic2</prov>
          <help id="Tab 1 Working">
          <Row>
          <Title>Panel 1 Item 1</Title>
          <description>My Description</description>
          <link>My Link</link>
          <pubDate>Mon, 10 Apr 2006 15:48:42 GMT</pubDate>
          </Row>
          <Row>
          <Title>Panel 1 Item 2</Title>
          <description>My Description</description>
          <link>My Link</link>
          <pubDate>Mon, 06 Mar 2006 15:48:42 GMT</pubDate>
          </Row>
          </help>
          </Item>
          <Item>
          <name>Tab 2</name>
          <ID>02</ID>
          <prov>Basic2</prov>
          <help id="Tab 2 Working">
          <Row>
          <Title>Panel 2 Item 1</Title>
          <description>My Description</description>
          <link>My Link</link>
          <pubDate>Mon, 24 May 2006 15:48:42 GMT</pubDate>
          </Row>
          <Row>
          <Title>Panel 2 Item 2</Title>
          <description>My Description</description>
          <link>My Link</link>
          <pubDate>Mon, 19 May 2006 15:48:42 GMT</pubDate>
          </Row>
          </help>
          </Item>
          <Item>
          <name>Tab 3</name>
          <ID>03</ID>
          <prov>Basic2</prov>
          <help id="Tab 3 Working">
          <Row>
          <Title>Panel 3 Item 1</Title>
          <description>My Description</description>
          <link>My Link</link>
          <pubDate>Mon, 06 Jul 2006 15:48:42 GMT</pubDate>
          </Row>
          <Row>
          <Title>Panel 3 Item 2</Title>
          <description>My Description</description>
          <link>My Link</link>
          <pubDate>Mon, 14 Jun 2006 15:48:42 GMT</pubDate>
          </Row>
          </help>
          </Item>
          </Root>