Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to filter DataGrid through the Flex combo box

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to filter DataGrid through the Flex combo box, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Filter DataGrid through the Flex combo box

A common application in Flex is to use Flex combo boxes to filter the data displayed in DataGrid. In this technique, the goal is to display the data from an "author" database table into DataGrid, which is structured as follows:

CODE:

AuthorId:String; authorName:String; status:String

◆ in addition, the user can filter the author information displayed by the Flex by selecting the values of different author states contained in the DataGrid combo box. It is recommended that you convert the result obtained from the server request to ArrayCollection, and then use this ArrayCollection as the dataProvider of DataGrid. In doing so, you will find it easy to manipulate and filter the displayed data. Getting data is beyond the scope of the current technique, but there are many examples of this problem.

First, convert the result to ArrayCollection.

CODE:

Importmx.utils.ArrayUtil; importmx.collections.ArrayCollection; / / event.resultcontainsthedatafromtheauthorssearch. PublicvarauthorsArray:Array=mx.utils.ArrayUtil.toArray (event.result); / / UseauthorsDataProviderasthedataProviderforthedataGrid. [Bindable] publicvarauthorsDataProvider:ArrayCollection=newArrayCollection (authorsArray)

◆ then dynamically loads the author status values from the search results into the Flex combo box. Here, the possible author status values in the database are "Active", "Inactive", and "Deleted". But before we proceed, let's review the use case. We display the results of the search author to the user through the DataGrid view, and after reading it, the user may want to filter the data to show only the author of "Active". Of course, the words "Active", "Inactive" and "Deleted" in the Flex combo box can be hard-coded directly, but if you do, we have to modify the program when a new state is added to the database.

Also, the value in the Flex combination box should contain only the author status in the search results, and if the search results include only authors with the status of "Active" and "Inactive", the Flex combination box should contain only the corresponding values (no "Delete"). If all possible author status values in the database are hard-coded in the Flex combo box, the user can select the value "Delete" and see a DataGrid without any data. We don't want to bother the user, so the following code dynamically loads the author status value into an array, which is then used as the dataProvider of the Flex combo box.

CODE:

/ / UsetheauthorsStatusArrayasthedataProviderfortheCombox. [Bindable] publicvarauthorsStatusArray:Array=populateAuthorsStatusArray (authorsArray); publicfunctionpopulateAuthorsStatusArray (authorsArray:Array): Array {varstatusArrayHashMap:Object=newObject (); varstatusArray:Array=newArray; varn:int=authorsArray.length; for (vari:int=0;i)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report