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 many ways are there for data binding in Flex

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is about how many ways of data binding are available in Flex. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Flex data binding

There are three ways for Flex to obtain data, which are HTTPService, WebService and DataModule. The following describes how to get xml data through objects and bind drop-down lists or table objects.

1. Flex data binding DataGrid

1. Go to the following menu to create a new flex project: File- > New- > FlexApplication. The wizard dialog box appears.

After selecting the default data access method, you need to set the project name and storage path in the following window. After setting up, click the "Finish" button.

2. After the project is established, a page with the extension * .mxml will be displayed in the main window, and the file name of the page will be the same as the project name. For example, in the following window, the developer can switch between Source mode and Design mode to edit the page.

Among them, Design mode is WYSIWYG design, and developers can select the desired objects from the list of controls on the left and drag them into the design page. As shown in the following figure, the optional visual objects include common objects such as buttons, check boxes, labels, and so on.

3. Select the DataGrid object and enter it into the page in design mode. The object is displayed as three columns by default.

4. Provide the xml data generated by the server for the page.

In order to simplify the difficulty of implementation, and to clarify the idea of implementation, the server-side file that provides data here is replaced by a local file.

Find the directory where the project file is located, and create a web page file that can generate xml data. The name of the file can be arbitrarily specified, and it is named dataSource.html here. The file contains the following:

Crickets float in Guangdong, Beijing, Shuiyue, Sichuan

Note: when saving the above file, you need to specify the encoding of the file as UTF-8, which is consistent with the xml encoding format contained in the file.

5. Next, you need to switch to the code editing mode of the page, add an object, and add the object to get the data generated by the specified file in the loader. Because the object is not displayed in the component panel, it needs to be entered manually. The attribute that needs to be modified is the value of url, and the rest of the attribute is fine by default.

6.Flex data binding modifies the properties of the DataGrid object.

The ndataProvider property is the data source and its value is: dataProvider= "{userRequest.lastResult.root.node}"

The dataField of the n data column object needs to be specified as a field name in the xml data, which can be "name" or "address".

The nHeaderText property is the column header.

Note that userRequest.lastResult represents the dataset obtained from the data source object, and userRequest.lastResult.root.node is equivalent to the collection of child nodes of xml data.

7.The object does not actively send the request, but still needs to call the object's send () method in the program to implement a http request.

You can execute a send request for a userRequest object in the creationComplete event of the object. The creationComplete event is equivalent to the onload event in a web page. The setting method is as follows:

After running the project file, the following window will pop up.

2. Flex data binding ComboBox

Of course, you can use ActionScript to traverse the data while adding every option in the drop-down list. You can also use a binding strategy.

1. Set the data source by:

DataProvider= "{userRequest.lastResult.root.node}"

2. Second, set the label field labelField:

LabelField= "name"

3. I need to find an attribute similar to dataField, but I don't seem to have it. I'll look for it again.

4. Events:

CreationComplete= "userRequest.send ()"

5. Flex data binding effect:

Thank you for reading! This is the end of this article on "how many ways of data binding in Flex". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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