8/2/2010 5:39:24 AM
Title:
Title window
I am opening a title window from a canvas.I have a datagrid im my Canvas.I want to get the value of the selected rows inside my title window.Please help.Thankyou
8/2/2010 5:56:31 AM
say you have a dataGrid in main application with id myDataGrid then it can be accessed using the Applicatio.application.myDataGrid from anywhere in the application . You can access your datagrid from the titlewindow using this and get the selelected items.
8/2/2010 6:35:04 AM
you can get the list of selected items as array on change event of the dataGrid by using the property
event.target.selectedItem
inside change listener function and then pass this array to your title window by declaring a public function inside your titlewindow component. i.e
say you titlewindow is "myTitleWindow" then call the function from with in change function
myTitleWindow.gridSelectedItems(event.target.selectedItem )
//function inside title window
public function gridSelectedItems(arr:Array):void{
//use the array of selected items
}
8/2/2010 9:38:18 PM
Thankyou for the reply .But the problem is I am opening the titleWindow from another window (not WindowedApplication) and the datagrid is in the Window.
I want to access the variables in the window from the title window.Please Help.
Thankyou.
Rayan
Points: 700
Posts:0
8/2/2010 10:03:07 PM
declare a public variable in the main application and on init of the titlewindow window set the reference to that public variable. Now you have the reference to link to dataGrid and you can use it as needed.
public var dGridReferenceVariable:DataGrid;
public variable should be accessible using parentDocument.dGridReferenceVariable or Application.application.dGridReferenceVariable
after setting this variable you can access any property of dataGrid
Davis
Points: 780
Posts:0
8/2/2010 10:12:17 PM
use the selectedItems property to get an array of all the selected rows in a datagrid
myDataGrid.selectedItems
8/2/2010 10:43:04 PM
Thankyou for the reply .
I will explain my problem once more.
I have a main application.
I am launching a new Window from the main application which is having a tabnavigator.
each tabnavigator contains a canvas.On a canvas I am having the datagrid.Now this Datagrid is having a button within it.I vam launching a titlewindow on this button click.
i want to access the datagrid inside this canvas.
8/3/2010 10:21:37 AM
john you didnt mention youa are using Adobe AIR or Flex application. I will try to give you the logic part.
//in your main mxml file create a public variable
public var dGrid:DataGrid;
//in your dataGrid init event set its reference in the declared variabel in root
<mx:DataGrid id="myDataGrid" dataProvider="{users}" initialize="{Application.application.dGrid=myDataGrid)}" >
Now you can see that when ever your dataGrid is create first time its reference is available in the variable in varibale "dGrid" and which can be accessed from any where using below code, this is your data grid now.
Application.application.dGrid
to see datagrid's selected items use
Application.application.dGrid.seletedItems and similarly other properties
8/16/2010 2:12:15 AM
Hello John ,
Please run the following codes, hope this is what you are looking for.
There are two files : main.mxml and comp.mxml
1] main.mxml
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.collections.ArrayCollection;
import mx.controls.DataGrid;
import mx.events.ListEvent;
private function handleDataGrid(event:ListEvent):void{
var _arr:ArrayCollection = (event.currentTarget as DataGrid).dataProvider as ArrayCollection;
var _obj:Object= _arr.getItemAt(event.rowIndex);
var comp:Comp = new Comp();
comp.gridValue = _obj;
PopUpManager.addPopUp(comp,this,true);
PopUpManager.centerPopUp(comp);
}
]]>
</mx:Script>
<mx:DataGrid itemClick="handleDataGrid(event)">
<mx:ArrayCollection>
<mx:Object Artist="Pavement"
Album="Slanted and Enchanted" Price="11.99" />
<mx:Object Artist="Pavement"
Album="Brighten the Corners" Price="11.99" />
<mx:Object Artist="Pavement"
Album="Prize" Price="11.99" />
</mx:ArrayCollection>
</mx:DataGrid>
</mx:Application>
2] Comp.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical" showCloseButton="true"
close="PopUpManager.removePopUp(this);">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
[Bindable]
private var _selObj:String;
public function set gridValue(value:Object):void{
_selObj = value.Album + " " + value.Artist + " " + value.Price;
}
]]>
</mx:Script>
<mx:Text text="{_selObj}" />
</mx:TitleWindow>
Hope this should show you some direction.
Regards,