[flexcoders] Re: Accessing a custom cellrenderer

2006-03-21 Thread t_msreddy



Look at the code below and try in similar lines in your cellRenderer file:

var rowIndex : Number;var columnIndex : Number;var getCellIndex : Function; // the function we receive from the listvargetDataLabel : Function; // the function we receive from the listfunction setValue( str:String, item:Object, sel:Boolean ) {//Dumper.info("@@This cell belongs to:" + str);if(rowIndex == undefined || columnIndex == undefined){rowIndex = getCellIndex().itemIndex;columnIndex = getCellIndex().columnIndex;}var projectMemberVO : ProjectMemberVO = ProjectMemberVO(item);var projectMemberWeekArray : Array = projectMemberVO.projectMemberWeekArray;if(!isNaN(Number(projectMemberWeekArray[columnIndex].forecastHours))  Number(projectMemberWeekArray[columnIndex].forecastHours) != 0) {//Dumper.info("projectMemberWeekArray[columnIndex].forecastHours setting to weekHoursForecast.text");weekHoursForecast.text = projectMemberWeekArray[columnIndex].forecastHours;} else{weekHoursForecast.text = "";}}function updateWeekHoursDataProvider(){if (!isNaN(weekHoursForecast.text)){ModelLocator.currentProject.projectTeamVO.projectMembersArray[rowIndex].projectMemberWeekArray[columnIndex].forecastHours = weekHoursForecast.text;}}



--- In flexcoders@yahoogroups.com, "digital_eyezed" [EMAIL PROTECTED] wrote: Hi,  I have a simple cellrenderer in a List which contains a checkbox.  I want to check through the list to see which items are checked.  Here is the cellrenderer:  ?xml version="1.0" encoding="utf-8"? mx:HBox styleName="wizardContainer" horizontalAlign="left"  xmlns:mx="http://www.macromedia.com/2003/mxml" width="100%"  height="100%" mx:Script ![CDATA[ var theLabel; var theData; function setValue(str:String, item:Object, sel:Boolean){ theLabel = String(item.label); theData = Number(item.data); } ]] /mx:Script mx:Spacer width="5"/ mx:CheckBox width="20" id="siteSelected" selected="false"/ mx:Text width="100%" text="{theLabel}"  styleName="cellRendererText"/ /mx:HBox  Here is the list:  mx:List cellRenderer="components.WizardCell" id="list2"  width="100%" height="100%"  dataProvider="{service.getMethod.result}"/  There is a Submit button below this which when clicked I want to  check through the list to see which items have been checked. Each  object in the list has a data and label attribute from the  dataProvider, ideally I would like to get an array of the data  attributes of those checked.  Cheers,  Iain






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  









[flexcoders] Re: Accessing a custom cellrenderer

2006-03-21 Thread Doug Lowder
Plenty of ways to accomplish this; one way is to provide a click 
handler for your checkbox, and then set a property of the 
corresponding dataprovider item that you can then examine from 
another function.  Cell renderers automatically get passed 
references to some handy objects and functions that you can use.

var listOwner: MovieClip; // the reference to the list
var getCellIndex: Function; // the function we receive

function onCheckboxClicked(event) {
listOwner.dataProvider.getItemAt(
getCellIndex().itemIndex).isCheckboxSelected = 
event.target.selected;
}

Just add click=onCheckboxClicked(event) to your mx:CheckBox, and 
any function can then loop through your dataprovider's items 
examining the isCheckboxSelected property to determine the state of 
the checkbox.

Doug

--- In flexcoders@yahoogroups.com, digital_eyezed 
[EMAIL PROTECTED] wrote:

 Hi,
 
 I have a simple cellrenderer in a List which contains a checkbox.
 
 I want to check through the list to see which items are checked.
 
 Here is the cellrenderer:
 
 ?xml version=1.0 encoding=utf-8?
 mx:HBox styleName=wizardContainer horizontalAlign=left 
 xmlns:mx=http://www.macromedia.com/2003/mxml; width=100% 
 height=100%
 mx:Script
 ![CDATA[
 var theLabel;
 var theData;
 function setValue(str:String, item:Object, sel:Boolean){
 theLabel = String(item.label);
 theData = Number(item.data);
 }
 ]]
 /mx:Script
 mx:Spacer width=5/
 mx:CheckBox width=20 id=siteSelected selected=false/
 mx:Text width=100% text={theLabel} 
 styleName=cellRendererText/
 /mx:HBox
 
 Here is the list:
 
 mx:List cellRenderer=components.WizardCell id=list2 
 width=100% height=100% 
 dataProvider={service.getMethod.result}/
 
 There is a Submit button below this which when clicked I want to 
 check through the list to see which items have been checked. Each 
 object in the list has a data and label attribute from the 
 dataProvider, ideally I would like to get an array of the data 
 attributes of those checked.
 
 Cheers,
 
 Iain








--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




RE: [flexcoders] Re: Accessing a custom cellrenderer

2006-03-21 Thread Tracy Spratt










To summarize, dont try to access
the rendered controls directly. Instead, have the cell renderer update the dataProvider,
then loop over the dataProvider to make your selected array.



Tracy











From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of t_msreddy
Sent: Tuesday, March 21, 2006 9:17
AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re:
Accessing a custom cellrenderer







Look at the code below and try in similar lines in your cellRenderer
file:











var rowIndex : Number;
var columnIndex : Number;

var getCellIndex : Function; // the function we receive from the list
vargetDataLabel : Function; // the function we receive from the
list

function setValue( str:String, item:Object, sel:Boolean ) {
//Dumper.info(@@This cell belongs to: + str);

if(rowIndex == undefined || columnIndex == undefined)
{
rowIndex = getCellIndex().itemIndex;
columnIndex = getCellIndex().columnIndex;
}
var projectMemberVO : ProjectMemberVO = ProjectMemberVO(item);
var projectMemberWeekArray : Array =
projectMemberVO.projectMemberWeekArray;
if(!isNaN(Number(projectMemberWeekArray[columnIndex].forecastHours))
 Number(projectMemberWeekArray[columnIndex].forecastHours) != 0) 
{
//Dumper.info(projectMemberWeekArray[columnIndex].forecastHours
setting to weekHoursForecast.text);
weekHoursForecast.text = projectMemberWeekArray[columnIndex].forecastHours;
} else
{
weekHoursForecast.text = ;
}


}

function updateWeekHoursDataProvider()
{
if (!isNaN(weekHoursForecast.text))
{
ModelLocator.currentProject.projectTeamVO.projectMembersArray[rowIndex].projectMemberWeekArray[columnIndex].forecastHours
= weekHoursForecast.text;
}

}
























--- In flexcoders@yahoogroups.com,
digital_eyezed [EMAIL PROTECTED] wrote:

 Hi,
 
 I have a simple cellrenderer in a List which contains a checkbox.
 
 I want to check through the list to see which items are checked.
 
 Here is the cellrenderer:
 
 ?xml version=1.0 encoding=utf-8?
 mx:HBox styleName=wizardContainer
horizontalAlign=left 
 xmlns:mx=http://www.macromedia.com/2003/mxml width=100%

 height=100%
 mx:Script
 ![CDATA[
 var theLabel;
 var theData;
 function setValue(str:String, item:Object, sel:Boolean){
 theLabel = String(item.label);
 theData = Number(item.data);
 }
 ]]
 /mx:Script
 mx:Spacer width=5/
 mx:CheckBox width=20 id=siteSelected
selected=false/
 mx:Text width=100% text={theLabel} 
 styleName=cellRendererText/
 /mx:HBox
 
 Here is the list:
 
 mx:List cellRenderer=components.WizardCell
id=list2 
 width=100% height=100% 
 dataProvider={service.getMethod.result}/
 
 There is a Submit button below this which when clicked I want to 
 check through the list to see which items have been checked. Each 
 object in the list has a data and label attribute from the 
 dataProvider, ideally I would like to get an array of the data 
 attributes of those checked.
 
 Cheers,
 
 Iain












--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.