473,788 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting an item in a datagrid

63 New Member
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.co m/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.select ed.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 3131
Tarik Monem
63 New Member
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
8880
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 can return the DataKey using the sub listed below. However, the select button does not have 'DataGridCommandEventArgs' as one of it's parameters so I cannot use the same command.
1
2242
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 caused me other problems. Any ideas? Thanks, Jay
0
1183
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 to populate a textbox with an item out of the selected row. I've implemented what seems to be the standard approach such as shown below to accomplishing this and the event works when selecting the select column link, when I make it visible,...
1
3354
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 able to find any examples which demonstrate how to do this. My Code:
3
15723
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 in USENET...get rewarded for it!
2
7500
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 nodes. The TreeView populates dynamically as there are a significant number of nodes. The DataGrid displays both the items and the nodes from the TreeView. Using the explorer analogy this means the TreeView shows folders, and the DataGrid folders...
0
2085
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 arrow it is not working can u tell me what are the properties i have to add to slect an item in processcmdkey method.
2
1359
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 the data the required data is displayed after executing a join query. i have wriitten code in selectindexchanged of dropdownlist box
4
1611
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 = New DirectoryInfo("C:/ImportFile/Coreland") ' FileListTable.Columns.Add("FullName", GetType(String)) FileListTable.Columns.Add("FileName", GetType(String)) FileListTable.Columns.Add("Length", GetType(Integer))
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.