Thanks Tracy.

This was indeed helpful.
>From last few weeks, I was struggling with REPEATERS while developing some
custom components and the way, you suggested me, brought me whole new idea
of putting custom components within repeaters rather then handling and
making changes in repeat events to standard components. It simplified the
things and ease the tension whereas modularize the application.

I had never tried the Tiles before and never had the idea of using them,
about the scenario like when, where and how to use them and after your
suggestion, tried with Tiles which simplified the things to a large extent.

Thanks to you Tracy.

Manu.
"The race is not over... because I have not won it yet."


Tracy Spratt wrote:
> 
> Create a custom component containing the checkbox.  Pass in currentItem,
> and a reference to existingData.  In a set itemData() method, run your
> loop, and assign the checkbox selected property value.
> 
>  
> 
> Below is some sample code.
> 
>  
> 
> Also, instead of three repeaters, you could use Tile, with
> direction="vertical"
> 
>  
> 
> Tracy
> 
>  
> 
> When working with Repeater, I advise creating a custom component that
> you will repeat, and pass it the entire "currentItem", In the component,
> implement a "setter" function to receive the currentItem data. 
> 
>  
> 
> Now, in the component, you can code normally, binding to the data as you
> wish, without the hard to read currentItem references. You also avoid
> the binding warnings without the cast/conversion because the binding
> source is a true XML object.
> 
>  
> 
> And, you can dispatch events normally.  In the event handler, you can
> reference the component via the event.target property, and thus get a
> direct reference to the dataProvider item.  This is easier to write and
> read than having to use getRepeaterItem().
> 
>  
> 
> Here are some code snippets:
> 
>  
> 
> In the main app or component (note how "clean" and readable this is):
> 
> <mx:Application
> 
> <mx:VBox ...>
> 
>   <mx:Repeater id="rp" dataProvider="{_xmlData}" ...>
> 
>     <mycomp:MyRepeatedComponent xmlItem="{rp.currentItem}" .../>
> 
>   </mx:Repeater
> 
> </mx:VBox>
> 
>  
> 
> And in the component, MyRepeatedComponent.mxml:
> 
> <?xml version="1.0" encoding="utf-8"?>
> 
> <mx:HBox ...
> 
> <mx:Script><![CDATA[
> 
>   [Bindable]private var _xmlItem:XML;
> 
>   
> 
>   public function set xmlData(xml:XML):void  
> 
>   {
> 
>     _xmlItem = xml;
> 
>     //do any special, non-bound ui stuff you want
> 
>   }//
> 
> ]]></mx:Script>
> 
>   <!-- Now declare the Item UI -->
> 
>   <mx:Text id="lbDescription" text="[EMAIL PROTECTED]"
> width="100%" height="100%" />
> 
>  
> 
>  
> 
>  
> 
>  
> 
>   
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Manu Dhanda
> Sent: Tuesday, October 30, 2007 1:30 AM
> To: [email protected]
> Subject: RE: Re[flexcoders] peater
> 
>  
> 
> 
> Hii Tracy,
> Here is my repeater(am using 3 repeaters, to have three columns to
> prevent
> having a scrollbar).
> Suggest me if there is any better way to do this, although it's not the
> issue at the moment.
> I have highlighted the problematic code in handler method below.
> Code for repeater:
> <mx:HBox id="hb" height="100%" width="100%">
> <mx:VBox id="vb1" height="100%" width="200">
> <mx:Repeater id="r1" dataProvider="{myData}" startingIndex="1"
> count="20"
> repeat="validateChecks(event)">
> <mx:CheckBox id="chkFirstColumn"
> label="{r1.currentItem.keyword_value_id}"
> data="{r1.currentItem}"/>
> </mx:Repeater> 
> </mx:VBox>
> <mx:VBox id="vb2" height="100%" width="200">
> <mx:Repeater id="r2" dataProvider="{myData}" startingIndex="21"
> count="20"
> repeat="validateChecks(event)">
> <mx:CheckBox id="chkSecondColumn"
> label="{r2.currentItem.keyword_value_id}" data="{r1.currentItem}"/>
> </mx:Repeater> 
> </mx:VBox> 
> <mx:VBox id="vb3" height="100%" width="200">
> <mx:Repeater id="r3" dataProvider="{myData}" startingIndex="41"
> count="20"
> repeat="validateChecks(event)">
> <mx:CheckBox id="chkThirdColumn"
> label="{r3.currentItem.keyword_value_id}" data="{r1.currentItem}"/>
> </mx:Repeater> 
> </mx:VBox> 
> </mx:HBox>
> 
> Code for Handler:
> private function validateChecks(e:Event):void{
> if(e.currentTarget.id == "r1" && existingData.length() > 0){
> for(var j:uint = 0; j < existingData.length(); j++){
> if(e.currentTarget.currentItem.keyword_value_key ==
> existingData[j].keyword_value_key){
> e.currentTarget.currentItem.selected = true; //Problem is here. It's not
> working.I want to refer the checkbox inside repeater here.
> }
> }
> }
> }
> 
> Tracy Spratt wrote:
>> 
>> If your repeated component has an id="myId", you can refer to
> individual
>> instances it by doing:
>> 
>> myId[n]. where n is the index of the repeater item. 
>> 
>> 
>> 
>> But from your description, I do not think this is what you want. If
>> you want to set the check box states based on data in the dataProvider
>> item, then you need to use currentItem.
>> 
>> 
>> 
>> Perhaps you should post a bit of the code.
>> 
>> 
>> 
>> Tracy
>> 
>> 
>> 
>> ________________________________
>> 
>> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
> ] On
>> Behalf Of Manu Dhanda
>> Sent: Wednesday, October 24, 2007 10:56 PM
>> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
>> Subject: RE: Re[flexcoders] peater
>> 
>> 
>> 
>> 
>> Hi Tracy
>> 
>> As I said, I need to check a few checkboxes based on the values from
> my
>> dataprovider, not all checkboxes. So, definitely, I need to refer each
>> and
>> every checkbox inside the repeater.
>> 
>> Or simply, say I have to do this 'selected' = true/false in a
>> eventhandler
>> method.
>> 
>> Now, how should I refer that checkbox inside a repeater??
>> Thanks,
>> Manu.
>> 
>> Tracy Spratt wrote:
>>> 
>>> You don't need a result handler for this. Just do:
>>> 
>>> <mx:CheckBox ... selected="{r1.currentItem.selected}"
>>> 
>>> 
>>> 
>>> Tracy
>>> 
>>> 
>>> 
>>> ________________________________
>>> 
>>> From: [email protected]
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
>> [mailto:[email protected]
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
>> ] On
>>> Behalf Of Manu Dhanda
>>> Sent: Tuesday, October 23, 2007 4:07 AM
>>> To: [email protected] <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com> 
>>> Subject: Re[flexcoders] peater
>>> 
>>> 
>>> 
>>> 
>>> Hii Guyz,
>>> 
>>> I have a Repeater(r1) and a checkbox(ch1) inside it.
>>> 
>>> I am passing a dataprovider dynamically to the repeater and based on
>> the
>>> values, I want to select a few checkboxes.
>>> 
>>> In the repeat event, e.currentTarget is referring to r1. 
>>> Now how can I refer the checkbox(ch1) inside it??
>>> 
>>> So, that I could do something: 
>>> e.currentTarget.currentItem.selected = true;
>>> 
>>> Please guide me.
>>> Thanks.
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/Repeater-tf4675803.html#a13359221
> <http://www.nabble.com/Repeater-tf4675803.html#a13359221> 
>> <http://www.nabble.com/Repeater-tf4675803.html#a13359221
> <http://www.nabble.com/Repeater-tf4675803.html#a13359221> > 
>>> <http://www.nabble.com/Repeater-tf4675803.html#a13359221
> <http://www.nabble.com/Repeater-tf4675803.html#a13359221> 
>> <http://www.nabble.com/Repeater-tf4675803.html#a13359221
> <http://www.nabble.com/Repeater-tf4675803.html#a13359221> > > 
>>> Sent from the FlexCoders mailing list archive at Nabble.com.
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Repeater-tf4675803.html#a13399388
> <http://www.nabble.com/Repeater-tf4675803.html#a13399388> 
>> <http://www.nabble.com/Repeater-tf4675803.html#a13399388
> <http://www.nabble.com/Repeater-tf4675803.html#a13399388> > 
>> Sent from the FlexCoders mailing list archive at Nabble.com.
>> 
>> 
>> 
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Repeater-tf4675803.html#a13482739
> <http://www.nabble.com/Repeater-tf4675803.html#a13482739> 
> Sent from the FlexCoders mailing list archive at Nabble.com.
> 
>  
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Repeater-tf4675803.html#a13524666
Sent from the FlexCoders mailing list archive at Nabble.com.

Reply via email to