Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 02-22-2010, 07:08 PM   #1
rogueblade
Senior Member
 
Join Date: Feb 2009
Location: London England
Posts: 166
Default Target row/datafield in data-grid

Hey guys I have a data-grid which is pulling information from a database through php (zend-amf)

ActionScript Code:
<mx:DataGrid id="reservationTbl" dataProvider="{amfcall.getReservations.lastResult}" editable="false" change="editReservation()" >     <mx:columns>         <mx:DataGridColumn headerText="Date" dataField="res_date" />         <mx:DataGridColumn headerText="Time" dataField="res_time" />         <mx:DataGridColumn headerText="Name" dataField="res_name" />         <mx:DataGridColumn headerText="Party Size" dataField="res_size" />         <mx:DataGridColumn headerText="Table" dataField="table_num" />         <mx:DataGridColumn headerText="Status" dataField="res_status" />     </mx:columns> </mx:DataGrid>

In my script I am trying to make a function which causes an event if a particular dataField from any of my Rows equals a certain criteria. Thing is I don't know how to target a data field or row. The only way I have targeted a row is with a change/click event on the data-grid itself which then populates a form.

I have a form item in which you input a number for the Party Size (res_size) and what I want is my function to check if the value in my form input is larger/different than what already exists in the database/grid. But I can't target the data field! Any idea how I can do this.
rogueblade is offline   Reply With Quote
Old 02-22-2010, 09:38 PM   #2
box86rowh
FLEX AND FLASH ARE COOL
 
Join Date: Oct 2005
Posts: 794
Default

you can just target the dataProvider, like :
ActionScript Code:
myGrid.dataProvider[4].res_size;
box86rowh is offline   Reply With Quote
Old 02-23-2010, 12:21 AM   #3
rogueblade
Senior Member
 
Join Date: Feb 2009
Location: London England
Posts: 166
Default

Hmm upon trying this I get the error
RangeError: Index '4' specified is out of bounds.
Or whatever number I put in the brackets. Am I correct in assuming that this is some sort of array collection of the data providers?
rogueblade is offline   Reply With Quote
Old 02-23-2010, 12:30 AM   #4
rogueblade
Senior Member
 
Join Date: Feb 2009
Location: London England
Posts: 166
Default

ok I take that back. If I put
myGrid.dataProvider[1].res_size;
it does work, but no other number will.....are you able to explain why this is??
rogueblade is offline   Reply With Quote
Old 02-23-2010, 01:35 AM   #5
box86rowh
FLEX AND FLASH ARE COOL
 
Join Date: Oct 2005
Posts: 794
Default

depends on how many records in the datagrid, 4 would be the fifth record in the set, 1 is the second one, as the set is zero indexed
box86rowh is offline   Reply With Quote
Old 02-23-2010, 01:35 AM   #6
rogueblade
Senior Member
 
Join Date: Feb 2009
Location: London England
Posts: 166
Default

I currently have 5 which is why I'm baffled
rogueblade is offline   Reply With Quote
Old 02-23-2010, 02:25 AM   #7
rogueblade
Senior Member
 
Join Date: Feb 2009
Location: London England
Posts: 166
Default

Ok nevermind mind I was making a stupid mistake, what you said does work thankyou. But what I would like to figure out now is how to check multiple datafields
So I tired this:
ActionScript Code:
myGrid.dataProvider[0,1,2,3,4].res_size;
But that gives me this error:
"ReferenceError: Error #1069: Property 4 not found on Number and there is no default value."
Or what ever is the lat number I put is the the number present in the error.

Do you know if I can check multiple data fields at the same time like what I'm trying to do in my example?
rogueblade is offline   Reply With Quote
Old 02-23-2010, 11:14 PM   #8
rogueblade
Senior Member
 
Join Date: Feb 2009
Location: London England
Posts: 166
Default

But does anyone know how I can target more than one datafield in a dataprovider, like my attempted example above?

Last edited by CyanBlue; 12-05-2010 at 08:21 AM.
rogueblade is offline   Reply With Quote
Old 02-24-2010, 04:13 AM   #9
box86rowh
FLEX AND FLASH ARE COOL
 
Join Date: Oct 2005
Posts: 794
Default

what is the scenario where u are checking multiple rows?
box86rowh is offline   Reply With Quote
Old 02-24-2010, 04:22 AM   #10
rogueblade
Senior Member
 
Join Date: Feb 2009
Location: London England
Posts: 166
Default

When I enter the party size for a reservation (left red circle) I want to check the "size" colum (right red circle) which is the number of seats a table has. This is so that I can flag all the tables which are smaller (less seats) than the number inputted in the form label "party size"


I was thinking of doing a loop in the script myGrid.dataProvider[i].res_size; but I wouldn't know what to tell 'i' to be greater/less than. In the php I could run a query to get the number of rows, but I don't know how to send that information to flex so I can use it in a loop function.

Last edited by rogueblade; 02-24-2010 at 04:25 AM.
rogueblade is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:27 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.