At first, I thought it was very simple. Just add an input checkbox in option. I found some implementation methods on the Internet and used the div layer to simulate the drop-down. I wanted to write one by myself based on this idea and the specific application of this project. It was too troublesome. I used extjs in another project, found an extension lovcombo, and learned its own example (with extjs of Version 2.3, version 3.x seems problematic ). The example is not difficult. The key is to add it to the existing code and change the original code as little as possible.
In the use of the drop-down multi-select box, more logic is processed mainly in the data source store configuration and select event processing. The data and UI separation mode of extjs makes cascade implementation very easy. You only need to update the store in the city drop-down list in the select event in the province drop-down list. Note that when an option is selected, you need to use the checkField value to determine whether the option is selected or canceled. There are also full selection, unall (the two lovcombo comes with the selectAll and deselectAll methods), and the number of selected options (you need to traverse the store and check the checkField value of each item ).
Copy codeThe Code is as follows:
// Select event in the drop-down box
Select: function (combo, record, index)
{
// Select
If (record. get (this. checkField ))
{
// Processing logic when selected
}
Else
{
// Unselected
}
}