Expand my Community achievements bar.

SOLVED

Data grid -Column data issue

Avatar

Level 2
Hi,



i am new to FDS using Flex 2.0.

Is it possible to the data in a datagrid column while loading
the page itself.




I have a product_list which contains hotel name , rate and
status.

Rate will be obtained from the list as say 345. i want to
display it as GBP 345 in datagrid, while page loading

how can i acheive this from client side ( in
actionscript)..?




My code for datagrid is as follows:



<mx:DataGrid id="dg" width="100%" rowHeight="38"
styleName="GridColumnText"

dataProvider="{hotel_details}"
enabled="{!ds.commitRequired}"
creationComplete="fill_hotelDetails()"

verticalScrollPolicy="{mx.core.ScrollPolicy.OFF}"
rowCount="10" height="404">

<mx:columns >

<mx:DataGridColumn dataField="hotel_address"
headerText="Hotel Name"

headerStyleName="DynamicLabel" width="300" wordWrap="true"
editable="false"/>



<mx:DataGridColumn id ="pr_rate"
dataField="prdt_rate" headerText="Rate"
headerStyleName="DynamicLabel" paddingRight="10" editable="false"
width="50" />



<mx:DataGridColumn dataField="hotel_status"
headerText="Availabilty"

headerStyleName="DynamicLabel" editable="false"
width="75"/>



<mx:DataGridColumn headerText="Book Now" editable="false"


headerStyleName="DynamicLabel" width="75"
sortable="false">

<mx:itemRenderer>

<mx:Component>

<mx:HBox width="25%" horizontalCenter="0"
horizontalAlign="center"

styleName="GridColumnText" paddingTop="5">

<mx:Button id="book" label="Book Now"
click="OnBook_click()" />

<mx:Script>

<![CDATA[

public function OnBook_click():void{

var request:URLRequest = new
URLRequest("/quick_search/booking.mxml");

navigateToURL(request,"_self");

}

]]>

</mx:Script>

</mx:HBox>

</mx:Component>

</mx:itemRenderer>

</mx:DataGridColumn>

</mx:columns>

</mx:DataGrid>



In the following code, i want to dispaly pdt_rate as GBP 345.
pls any one give suggestions



thx in advance

Ambili Surendran
1 Accepted Solution

Avatar

Correct answer by
Level 4
I think the best way is to make a label function something
like this (just off the top of my head, not tested):



public function rate_label(item:Object,
column:DataGridColumn):String

{

return "GBP"+item.prdt_rate;

}



Then in the DataGridColumn add a property:



labelFunction="rate_label"



View solution in original post

2 Replies

Avatar

Correct answer by
Level 4
I think the best way is to make a label function something
like this (just off the top of my head, not tested):



public function rate_label(item:Object,
column:DataGridColumn):String

{

return "GBP"+item.prdt_rate;

}



Then in the DataGridColumn add a property:



labelFunction="rate_label"



Avatar

Level 2
hi Robert,



Thank you for ur immediate reply.. .

it worked...



thnx

Ambili surendran