Solved

Flex4 - DataGrid CheckBox (Check Everything)

Posted on 2010-09-12
3
2,358 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
  • 2
3 Comments
 
LVL 4

Expert Comment

by:andreMariano
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
WHY MVC is the future technology... As many of you know, MVC is Model,View,Controller pattern. Model View Controller pattern was invented in a Smalltalk context at Xerox in late 1970s. Why is this buzz about MVC: --------------------------- …
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now