Checkbox itemrenderer in datagrid

January 5, 2012

The selected property of the checkbox has to be bounded with the selected property of our entity,  Itemrenderer doesn’t keep track of the selected states correctly this can be fixed by binding data with selected property.Freelance Flash Flex developer India Bangalore

The below code explains the itemrender file called DGCheckBoxEditor

<mx:Script>
<![CDATA[
import mx.controls.listClasses.ListData;
import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.listClasses.BaseListData;
import mx.controls.dataGridClasses.DataGridItemRenderer
import mx.events.FlexEvent;

private var _listData:DataGridListData;
// Define a property for returning the new value to the cell.
public var cbSelected:Boolean;

// Implement the drawFocus() method for the VBox.
override public function drawFocus(draw:Boolean):void {
followUpCB.setFocus();
}

[Bindable]
override public function set data(value:Object):void{
super.data = value;
followUpCB.selected=data[_listData.dataField];
}

override public function get data():Object {
return super.data;
}

public function get listData():BaseListData
{
return _listData;
}

public function set listData(value:BaseListData):void
{
_listData = DataGridListData(value);
}

]]>
</mx:Script>

<mx:CheckBox id=”followUpCB”
change=”cbSelected=followUpCB.selected” paddingLeft=”15″/>

Code to call the itemrender

<mx:DataGrid id=”myGrid”
dataProvider=”{myAC}” editable=”true” >
<mx:columns>
<mx:DataGridColumn id=”checker” dataField=”FollowUp”
width=”50″
headerText=”Select”
itemRenderer=”DGCheckBoxEditor” rendererIsEditor=”true”
editorDataField=”cbSelected”/>
<mx:DataGridColumn id=”checker1″ dataField=”Contact” width=”150″ />
<mx:DataGridColumn dataField=”id” width=”150″ editable=”false”/>
</mx:columns>
</mx:DataGrid>

Advertisements

What we do

December 1, 2008

We are into new media development with high quality of innovation and skill. We create applications that not only fulfill the purpose but wow and impress the user/visitor. Our basic idea is in redefining the way people interact with web through introduction of highly advanced, yet affordable, customized solutions.

We provide services in Flex and Flash development, E-learning, graphic design and multimedia. We always push the envelope for a fresh new look. We recognize that every client is unique that is why we provide the highest level of creativity and client service.

We’ll take the time to know the details of your business to ensure that we exceed your expectations. Direct principle and project manager involvement is possible throughout all phases of the project to ensure the highest quality. You have our commitment not only to quality but to the highest level of customer service.

The bottom line, We build innovative and scalable strategies that harness the power of the web for your business and offer to you extremely profitable & cooperative conditions through strong resources and highly qualified & experienced manpower.