473,320 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Selecting an item in a datagrid

Hi Everyone,

I've been trying to do this application that I've been working on from so many different angels and I seem to be running into some kind of wall with every attempt. I have scrapped each attempt and it should be easy, but it's not.

I have simplified the app drastically by just having a datagrid being populated with the names of images from an array, which was populated via LoadVars. From there, I want to click on one of the cells(the name of an image) within the Datagrid and load the image into a MovieClip, but I continue to receive the message that "http://www.mydomain.com/registration/images/undefined."

image1 is my Loader on stage

Here's the code
Expand|Select|Wrap|Line Numbers
  1.  
  2. function defineListener() 
  3. {
  4.     var listener:Object = new Object();
  5.     listener.headerRelease = function(evt:Object) 
  6.     {
  7.     columnHighlight(evt.columnIndex);
  8.     };
  9.     listener.cellPress = function(evt:Object) 
  10.     {
  11.         getImage();
  12.         msg_ta2.text = "you clicked a cell";
  13.     }
  14.     dataGridMain.addEventListener("headerRelease", listener);
  15.     dataGridMain.addEventListener("cellPress", listener);
  16. }
  17.  
  18. defineListener();
  19.  
  20. function getImage() 
  21. {
  22.    var cartGrid = dataGridMain;
  23.    var someNumber:Number = cartGrid.getSelectedIndex();
  24.     var someWords:String = cartGrid.getSelectedItem;
  25.    var imageSource:String = 'http://www.mydomain.com/registration/images/' + someWords;
  26.    image1.load(imageSource);
  27. }
  28.  
  29.  
I've tried to set someWords to cartGrid.selected.data -- I've tried setting imageSource to imageAray[someNumber];

But it always returns undefined? How can I successfully populate a datagrid and then not be able to retrieve the value of a particular cell?

Thanks in advance
Oct 22 '07 #1
1 3112
After a lot of reading over the internet, I came across this solution.

Expand|Select|Wrap|Line Numbers
  1.  
  2. function defineListener() 
  3. {
  4. var myListener = new Object();
  5.     myListener.cellPress = function(eObj) 
  6.     {
  7.          et = eObj.target;
  8.          var cell = "(" + eObj.columnIndex + ", " + eObj.itemIndex + ")";
  9.          // trace(" The cell at " + cell + " has been clicked ");
  10.          // trace("Cell Text: " + et.getItemAt( eObj.itemIndex)[et.getColumnAt(eObj.columnIndex).columnName] );
  11.  
  12.          var imageSource:String = 'http://mydomain.com/registration/images/' +  et.getItemAt( eObj.itemIndex)[et.getColumnAt(eObj.columnIndex).columnName];
  13.          image1.load(imageSource);
  14.     };
  15. dataGridMain.addEventListener("cellPress", myListener);
  16. }
  17.  
  18.  defineListener();
  19.  
  20.  
Oct 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stu | last post by:
Hi, I am trying to return the data key field value from a dataset when I select a row in a datagrid after the datagrid has been bound to a dataset. When I an the Edit, Update and Cancel row I...
1
by: Jay | last post by:
Hi All, My users are complaining about the page refreshing when they are selecting multiple rows in a datagrid. Has anyone tried to manage this using javascript? I tried smartnavigation but that...
0
by: Steven W | last post by:
I'm trying to setup a datagrid in a custom control where I can select the row with the Select column hidden and have it call the "SelectIndexChanged" event. In the "SelectIndexChanged" I just want...
1
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been...
3
by: larry mckay | last post by:
anyone have the code to select and listview item or row (subitems) after a doubleclick event from a listview. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate...
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
0
by: koti | last post by:
hi i have written some code for selecting an item in combobox dropdown list which is in datagrid columm. by scrolling the mouse we select any item from the list. but by pressing the down key...
2
by: yogeshtiwarijbp | last post by:
when i select data from the drop down list box and display data in the datagrid the first data in the dropdownlistbox not shown the requireddata in the grid. i have used 2 tables and after selecting...
4
by: tshad | last post by:
I have a dataGrid that I filled with files from my directory. I am using VS 2003 and Windows Forms. ************************************************************ Dim dirInfo As DirectoryInfo =...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.