Solved

Flex4 - DataGrid CheckBox (Check Everything)

Posted on 2010-09-12
3
2,386 Views
Last Modified: 2012-06-27
im using FlashBuilder here,

anyway i have a simple DataGrid, with 2 columns,

one of them has a custom itemrenderer that has a checkbox in it (but i dont use any source for the selected true/false)
and the other column is a basic one ,

 now i am manually adding to the data source a new item that says "All of Them"

so i need that when the user check the checkbox for the "All of Them" it all automatically check all checkboxs for the datagrid.. if the user unselects then it will uncheck all of them but dont know how to access the checkbox in the custom item renderer for every row..

also i need a method that will return all items that are currently with the checkbox marked.. (but i suppose the answer for this one will come from the first aswell)

does anyone have any ideia how to do something like this ?

(is a DataGrid the best choice for something like this or perhaps a list or advdatagrid would be better ? )

Thx

ps. is there a flash builder section ?
0
Comment
Question by:eguilherme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Expert Comment

by:andreMariano
ID: 33660905
This one is kind fun...
ok... to select or unselect this checkbox, there is an certain field in your dataprovider that sets if it is selected or not, right?
so, when you click in "all of them"
you can create an loop in all your dataprovider setting the field to 1
and when you click "none", you do that same loop setting the field to 0
0
 
LVL 10

Author Comment

by:eguilherme
ID: 33664778
yea but thats the thing, i dont have any field on the dataprovider for that checkbox values..

its something like this, my dataprovider is a list of companies.. and i want those in a datagrid where the person can select which or all companies to select and then i will capture the id property of the dataprovider of those who have been selected and send to a webservice

oh well, i guess its easier to create a component to simulate a row and add those in a displaycontainer (group/etc)..
0
 
LVL 4

Accepted Solution

by:
andreMariano earned 500 total points
ID: 33665116
Well, what I suggest is manually adding a field in your dataProvider, something like "SELECTED" = 1 or 0
then in your renderer, you override your set Data method, and then, each time you set your field to 1 or 0, the "set data" method is called...
ex.

public class CheckCellRenderer extends CheckBox
	{
		public var columnName : String;
		
		
		function CheckCellRenderer() {
			super();
			
			addEventListener(MouseEvent.CLICK , change, false, 0, true);
			
			selected = false;
		}

		// Override the set method for the data property.
        override public function set data(value:Object):void {
        	super.data = value;
        	
        	
        	
        	selected = (data[columnName] == "1");
        	
        	
        }
        
		public function change(event:Event){
			if ( selected ) {
				data[columnName] = "1";	
			} else {
				data[columnName] = "0";
			}
		}
	}

Open in new window

0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTTPS upload and download website building help 4 48
advanced wordpress question 3 124
Apex, changing the home page, by condition 3 96
Intranet for business 4 154
First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question