Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-01-2012, 02:05 PM   PM User | #1
sinild
New to the CF scene

 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
sinild is an unknown quantity at this point
Issues with Dynamic datagrid that has itemRenderer

Hi,

I am in a real dilemma. I'll be so thankful, if someone can look into this issue and provide me some help.

I need to fetch my DB tables and show it on a page. Since the tables are so dynamic, my columns differ.
Also, on Flex Page > data grid, in the beginning of each row, I need to show a check box, which allows me to select and unselect a row item.

Here is my XML
[CODE]
<?xml version="1.0"?>
-<root>-<result>
-<row><eSelect>FALSE</eSelect><TC_ID>204</TC_ID><TP_ID>1</TP_ID><SKU>LSID3409</SKU><Smoke>0</Smoke><Sanity>0</Sanity><Active>1</Active><Rerun>3</Rerun><DTSID>0</DTSID><UUID>TBD</UUID><ActivationTypeID>9</ActivationTypeID></row>-
<row><eSelect>..............................................................
[CODE]

In the above XML you can see the tag 'eSelect' is the tag I added for this tag to handle checkbox on the Flex Data grid.

Here is my Flex Code:


[CODE]
//Server Response Handler (Result Handler Function):
private function onResults(event:ResultEvent) : void {
var xml:XML = new XML(event.result.toString());
var columnataGridColumn = new DataGridColumn();
actTCList = new XMLList(xml.result.row);

var colarr:Array = TCDataGrid.columns;
for (var i:int = 1; i < actTCList[0].children().length(); i++) {
column.dataField = actTCList[0].children()[i].name();
column.showDataTips = true;
column.dataTipField = actTCList[0].children()[i].name();
colarr.push(column);
}

TCDataGrid.columns = colarr;
}


//Component Definition
<s:BorderContainer>
<mxataGrid id="TCDataGrid" fontWeight="normal" bottom="2" left="5" right="5" top="105" wordWrap="true" variableRowHeight="true" editable="true" dataProvider="{actTCList}">
<mx:columns>
<mxataGridColumn headerText="" width="15" dataField="eSelect" sortable="false" editable="false">
<mx:itemRenderer>
<fx:Component>
<mx:VBox>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
protected function select_changeHandler(event:Event):void
{
// TODO Auto-generated method stub
if (select.selected) {
outerDocument.TCDataGrid.selectedItem.eSelect = 'true';
}
else {
outerDocument.TCDataGrid.selectedItem.eSelect = 'false';
}
}
]]>
</fx:Script>
<s:CheckBox id="select" change="select_changeHandler(event)" selected="{data.eSelect == 'true'}"/>
</mx:VBox>
</fx:Component>
</mx:itemRenderer>
<mx:headerRenderer>
<fx:Component>
<mx:VBox>
<fx:Script>
<![CDATA[
protected function selectAll_changeHandler(event:Event):void
{
// TODO Auto-generated method stub
var i:int;
if (selectAll.selected) {
for(i = 0; i < outerDocument.actTCList.length(); i++) {
outerDocument.actTCList[i].eSelect = 'true';
}
}
else {
for(i = 0; i < outerDocument.actTCList.length(); i++) {
outerDocument.actTCList[i].eSelect = 'false';
}
}
}
]]>
</fx:Script>
<s:CheckBox id="selectAll" change="selectAll_changeHandler(event)"/>
</mx:VBox>
</fx:Component>
</mx:headerRenderer>
</mxataGridColumn>
</mx:columns>
</mxataGrid>
</s:BorderContainer>
[CODE]

But, this doesn't work. When I run the web application, I see two columns. First column contain the checkboxes. Inside the second column, I see another set of columns(columns inside columns) and the header name of the second column is the name of the last tag in the XML (ActivationTypeID).

I couldn't find any suffiecient help on this. Can you please help me?

Thanks,
Sinil
sinild is offline   Reply With Quote
Old 02-06-2012, 04:41 AM   PM User | #2
sinild
New to the CF scene

 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
sinild is an unknown quantity at this point
Can someone please help?
sinild is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:55 AM.


Advertisement
Log in to turn off these ads.