In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces Flex data binding skills, the article is very detailed, has a certain reference value, interested friends must read it!
Flex data binding skills
There is an easy way to activate / disable controls by selecting them. For example, suppose you have a DataGrid and buttons that manipulate data, some of which can only be used when a row is selected, others can only be used when unselected, and some can only be used when a specific row is selected.
problem
To do this, you may need to write some if statements or use Flex data binding to set a variable and then constantly adjust the value of the variable in the code. It's like this:
Program code
[Bindable] privatevarsomethingSelected:Boolean=false
That's a good idea. All controls that depend on the selected state of DataGrid are bound to a variable. Changing this variable changes the active state of the control. However, you still need to decide when to change this variable. For example:
Program code
PrivatefunctionpublishItem (): void {/ / gettheselecteditem / / publishit grid.selectedItem=-1;//cleartheselection somethingSelected=false;}
Let's complicate things a little bit, assuming that the selected row contains a special value and a button will be activated. Now you need to pay attention not only to the variable somethingSelected, but also to this additional check. In other words, you need to set another variable in the publishItem () function. The more conditions there are, the more complex the function will be.
A simpler method
Here is a simpler way to do this. Now that the button is bound to the somethingSelected variable, all that's left is to bind the somethingSelected variable to the state of DataGrid. You can use the tag:
Program code
Now the value of somethingSelected is bound to the selected state of DataGrid. Selecting a row of somethingSelected changes to true, then all tags with enabled= "{somethingSelected}" will be activated, and buttons with enabled= "{! somethingSelected}" in all tags will be disabled.
The source of the ◆ Bingding tag does not have to be a variable. It can be an expression, as shown below. Here source is a simple condition to determine whether the selectedIndex of DataGrid is greater than or equal to 0.
Here is a slightly more complicated example:
Program code
A value of 1 for a field of a record in DataGrid will change the value of the variable codeOnePicked to true.
Program code
Here, as long as the selected record code field in DataGrid is 1, the Magi CheckBox is selected and the button is disabled.
These are all the contents of the article "what are the Flex data binding techniques?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.