Mar 24 2006

Flex 2 itemRenderer: Bonehead!

Posted by Joe Rinehart at 11:22 AM
4 comments
- Categories: Flex and ColdFusion

It looks like I just learned a basic lesson about Flex 2 databinding. Thanks go out to Dirk, who pointed out that I wasn't modifying the data that the checkbox was bound to in my previous post, so that when then item renderer was "recycled," it got "dirty" state.

Here's a revision of my earlier MXML that works properly:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"   layout="vertical" width="100%" height="100%">
   <mx:Script>
      <![CDATA[
         import mx.collections.ArrayCollection;
         
         var items:ArrayCollection = getItems();
         
         public function getItems():ArrayCollection {
            var i:int;
            var items:ArrayCollection = new ArrayCollection();
            for (i=0;i<50;i++) {
               var item:Object = new Object();
               item["label"] = i.toString();   
               item["selected"] = false;
               items.addItem(item);
            }
            
            return items;
         }
      ]]>
   </mx:Script>

   <mx:List dataProvider="{items}" width="200" height="200">
      <mx:itemRenderer>
         <mx:Component>
            <mx:Canvas>
               <mx:CheckBox id="complete" width="20" x="10" y="4" selected="{data.selected}" click="{data.selected = complete.selected}"/>
               <mx:Text id="taskname" text="{data.label}" x="27" width="100%" y="4" selectable="false" />         
            </mx:Canvas>
         </mx:Component>
      </mx:itemRenderer>
   </mx:List>
</mx:Application>

Comments

Dirk

Dirk wrote on 03/24/06 3:10 PM

You're welcome :)

Btw, you don't need to use square brackets if you want to set properties on an Object instance, i.e. this also works: item.label = i.toString();

Dirk.
power batteries

power batteries wrote on 09/27/08 11:42 PM

Thanks go out to Dirk, who pointed out that I wasn't modifying the data that the checkbox was bound to in my previous post, so that http://www.batteryfast.com/hp/nc8000.htm hp nc8000 battery,
http://www.batteryfast.com/hp/v1000.htm hp v1000 battery,
http://www.batteryfast.com/hp/nx4300.htm hp nx4300 battery,
http://www.batteryfast.com/hp/b1800.htm hp b1800 battery,
http://www.batteryfast.com/hp/hstnn-a14c.htm hp hstnn-a14c battery,
http://www.batteryfast.com/hp/b1829tu.htm hp b1829tu battery,
http://www.batteryfast.com/hp/b2000.htm hp b2000 battery,
http://www.batteryfast.com/hp/hstnn-b071.htm hp hstnn-b071 battery,
http://www.batteryfast.com/hp/lb32111b.htm hp lb32111b battery,

http://www.batteryfast.com/hp/dv2000.htm hp dv2000 battery,
http://www.batteryfast.com/hp/dv2100.htm hp dv2100 battery,
http://www.batteryfast.com/hp/dv2200.htm hp dv2200 battery,
http://www.batteryfast.com/hp/dv6000.htm hp dv6000 battery,
http://www.batteryfast.com/hp/520.htm hp 520 battery,
http://www.batteryfast.com/hp/500.htm hp 500 battery,
http://www.batteryfast.com/hp/hstnn-ib44.htm hp hstnn-ib44 battery,
http://www.batteryfast.com/hp/nc4000.htm hp nc4000 battery,
http://www.batteryfast.com/hp/nc4010.htm hp nc4010 battery,

http://www.batteryfast.com/hp/dd880.htm hp dd880 battery,
http://www.batteryfast.com/hp/315338-001.htm hp 315338-001 battery,
http://www.batteryfast.com/ibm/02k6620.htm ibm 02k6620 battery,
http://www.batteryfast.com/ibm/thinkpad-t20.htm ibm thinkpad t20 battery,
http://www.batteryfast.com/ibm/02k7072.htm ibm 02k7072 battery,
http://www.batteryfast.com/ibm/thinkpad-t30.htm ibm thinkpad t30 battery,
http://www.batteryfast.com/ibm/thinkpad-r50.htm ibm thinkpad r50 battery,
http://www.batteryfast.com/ibm/thinkpad-t40.htm ibm thinkpad t40 battery,
http://www.batteryfast.com/ibm/08k8192.htm ibm 08k8192 battery,
when then item renderer was "recycled," it got "dirty" state.
Michael

Michael wrote on 09/29/08 3:44 AM

It looks like I just learned a basic lesson about Flex 2 databinding. Thanks go out to Dirk, who pointed out that I wasn't modifying the data that the checkbox was bound to in my previous post, so that when then item renderer was "recycled," it got "dirty" state.
http://www.batteryfast.co.uk/dell/312-0341.php 3cell Battery for Dell Latitude X1 T6840 312-0342 Y6457 laptop battery,
http://www.batteryfast.co.uk/dell/xd187.php New Dell Inspiron B130 1300 b120 Battery 312-0416 56whr laptop battery,
http://www.batteryfast.co.uk/gateway/m680.php Gateway M360 M460 M680 8-Cell Notebook Battery 6500949 laptop battery,
http://www.batteryfast.co.uk/hp/hstnn-db17.php New Battery for HP M2000 Series DV1000 DV4000 laptop battery,
http://www.batteryfast.co.uk/hp/f2019b.php Battery For HP F2019 F2019A F2019B 6000 VT6200 XT6200 laptop battery,
http://www.batteryfast.co.uk/hp/hstnn-db02.php Battery For HP HSTNN-IB04 346970-001 HSTNN-DB02 DP399A laptop battery,

http://www.batteryfast.co.uk/hp/n3402.php New F1739A Battery For HP XE XE2 Pavilion N3000 N3490 laptop battery,
http://www.batteryfast.co.uk/hp/zt1000.php New Battery For HP Pavilion ZT1000 F2299A F3172B F3172A laptop battery,
http://www.batteryfast.co.uk/ibm/02k7018.php IBM THINKPAD 600 600A 600D 600E 600X 02K7018 BATTERY laptop battery,
http://www.batteryfast.co.uk/gateway/btp-68b3.php Battery for Gateway Solo M500 M505 Medion MD2900 MD6179 laptop battery,
http://www.batteryfast.co.uk/toshiba/pa3382u-1brs.php Battery Fit Toshiba PA3382U-1BRS PA3384U-1BRS laptop battery,
http://www.batteryfast.co.uk/toshiba/pa3421u-1brs.php Battery for Toshiba M30X M35X M40X PA3395U-1BRS PA3421U laptop battery,

http://www.batteryfast.co.uk/toshiba/pa3465u.php Genuine TOSHIBA PA3465U-1BRS Laptop Battery PABAS069 laptop battery,
http://www.batteryfast.co.uk/gateway/6500358.php battery for solo 9300 6500358 GT-6300L laptop battery,

Write your comment



(it will not be displayed)