简体   繁体   English

Flex,将SQLite结果放入ItemRenderer

[英]Flex, Putting SQLite result into a ItemRenderer

Using the following SQLite statement: 使用以下SQLite语句:

SELECT Customer, SUM(OrderAmount) AS TotalOrder FROM OrdersTable GROUP BY Customer 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 ? 如何将上述结果放入itemRenderer label.text?

<s:ItemRenderer>
   <s:Label id="customerName" text=??? />
   <s:Label id="totalOrder" text=??? />
</s:ItemRenderer>

thanks 谢谢

Whenever we set data to a dataprovider it automatically set to its item renderer, if you are using custom itemrendere then do this... 每当我们将数据设置为数据提供者时,它会自动设置为其项目渲染器,如果您使用自定义itemrendere,则执行此操作...

[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> 

ItemRenderer 's have a data property which the Flex List control sets on each renderer. ItemRenderer有一个data属性,Flex List控件在每个渲染器上设置该属性。 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. 您可以将Labeltext属性绑定到数据,覆盖data属性的setter,或为“dataChange”事件添加事件侦听器。

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 ;) 这假设您的List的数据提供程序已填充w /具有属性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: 您可以找到许多使用Flex ItemRenderer ,例如:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM