tags:

views:

99

answers:

2

Am using Checkbox as ItemRenderer in tilelist. Am trying to setting checkbox selected values through xml. I got the values perfectly.. but checkbox could not bind the values(could not accept that). It's automatically sets true for all checkboxes. This is my xml

<PmhTreeAllow>
  <PmhTreeAllowname id='1' label ='Allow Text' isField='false'/>
  <PmhTreeAllowname id='2' label ='Document Link' isField='false'/>
  <PmhTreeAllowname id='3' label ='Test Results Entry'isField='false'/>
  <PmhTreeAllowname id='4' label ='Dummy' isField='false'/>
</PmhTreeAllow>

My Tilelist..

<mx:TileList id="tileList" width="160" height="100%" textAlign="left" horizontalScrollPolicy="off" verticalScrollPolicy="off" dataProvider="modelInstance.optionCollList}" columnCount="1" backgroundAlpha="0" borderStyle="none"itemRenderer="com.Frontend.views.treeStructure.myTileList" useRollOver="false" rowHeight="28" itemClick="tileItemClick(event)" columnWidth="150" selectedIndex="0" x="10" y="0">

Check box ItemRenderer..

<?xml version="1.0" encoding="utf-8"?>
<mx:CheckBox xmlns:mx="http://www.adobe.com/2006/mxml" label="{data.@label}" selected="data.@isField}"/>

Thanks in Advance Ashok

A: 

http://www.switchonthecode.com/tutorials/flex-using-item-renderers

This will help u..

It's working in Datagrid.. I have a problem in TileList..
Aswath
A: 

For performance reasons, it is considered a bad practice to use binding inside an itemRenderer. Instead listen to the FlexEvent.DATA_CHANGE and manually modify your values. I Bet doing so will solve your issue.

Try an itemRenderer like this:

<mx:CheckBox xmlns:mx="http://www.adobe.com/2006/mxml" label="{data.@label}" selected="data.@isField}" dataChange="onDataChange()">
<mx:Script><[[
 public function onDataChange():void{
 var dataAsXML = data as XML; 
 this.selected = data.@isField
 this.label = data.@label
]]></mx:Script>
</mx:CheckBox>

I don't do a lot with XML, but I suspect that the XML properties will not bind because XML is not like an ActionScript object and therefore the "propertyChanged" Binding events do not exist on the XML object the same way they would be on an AS3 object.

www.Flextras.com