Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Doing select all in flex is little complex but I will tell you the way we did it and it works great.</p> <p>We created a List derived control called "ExList" which has a property "selectAllCB" which we bind it to existing check box which will work for select all logic. Please note, when we set selectAllCB property, we make ExList to listen to checkbox's events.</p> <p>When checkbox is checked, we manually set selectedItems array to array of dataProvider and all items are selected.</p> <p>Playing with itemRenderer doesnt work correctly because when you program your list again and again everytime you have to write so much of code.</p> <pre><code>I am attaching some sample code here below.. public class ExList extends List { public function ExTileList() { super(); this.allowMultipleSelection = true; } private var _selectAllCB:CheckBox = null; [Bindable] public function get selectAllCB():CheckBox { return _selectAllCB; } public function set selectAllCB(v:CheckBox):void { if(v==null) return; _selectAllCB = v; v.addEventListener(ListEvent.ITEM_CLICK, handleAllChange,false, 0 , true); v.addEventListener("change", handleAllChange,false, 0 , true); } private function handleAllChange(e:Event):void { if(_selectAllCB.selected) { this.selectedItems = this.dataProvider.toArray(); } else { this.selectedItems = new Array(); } } } </code></pre> <p>And you can use it as...</p> <pre><code>&lt;CheckBox id="sAll"/&gt; &lt;ExList selectAllCB="{sAll}"/&gt; // Please note its in curly braces </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload