Reputation: 265
Using the following SQLite statement:
SELECT Customer, SUM(OrderAmount) AS TotalOrder FROM OrdersTable GROUP BY Customer
I get the result of total sum (total order) of each customer
How can I put the above result into a itemRenderer label.text ?
<s:ItemRenderer>
<s:Label id="customerName" text=??? />
<s:Label id="totalOrder" text=??? />
</s:ItemRenderer>
thanks
Upvotes: 0
Views: 254
Reputation: 18193
ItemRenderer
's have a data
property which the Flex List control sets on each renderer. You can bind the text
property of a Label
to the data, override the setter for the data property, or add an event listener for the "dataChange" event.
When binding you can use curly brace expressions like this:
<s:Label text="{data.customerName}" />
This assumes that the data provider for your List
is populated w/an object that has the property customerName
;)
The other two approaches require that you write some code that sets the label's text property.
You can find many examples of using a Flex ItemRenderer
, such as these:
Upvotes: 0
Reputation: 162
Whenever we set data to a dataprovider it automatically set to its item renderer, if you are using custom itemrendere then do this...
[Bindable] private var _customerName:String;
[Bindable] private var _totalOrder:String;
override public function set data(value:Object):void{
this.data = value;
_customerName = value. property //propertyName containing customer name
_totalOrder = value. property //propertyName containing totalOrder
}
<s:Label id="customerName" text="{_customerName}" />
<s:Label id="totalOrder" text="{_totalOrder}" />
or
<s:ItemRenderer>
<s:Label id="customerName" text="{data.properyNamecontainCustomerName}" />
<s:Label id="totalOrder" text="={data.properyNamecontaintotalOrder} " />
</s:ItemRenderer>
Upvotes: 2