RE: [flexcoders] Select all checkboxes in datagrid with a single click

2008-03-21 Thread Tracy Spratt
No, no, I'm just trying to make this key idea,
"work-with-the-dataProvider", clear to the original poster, clearly a
new Flex user.  I don't even need to look at your example to know it is
quality.  I apologize for the misunderstanding.

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Scott Melby
Sent: Friday, March 21, 2008 12:30 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Select all checkboxes in datagrid with a
single click

 

Tracy -

Not sure if you are referring to my sample code. But, just in case you 
are... That code *does* update the underlying data provider. It simply 
does it generically using ICollectionView and IViewCursor. This is not 
looping over the renderers afaik. If it is, I'd sure like to know... 
cuz I wouldn't recommend doing that either :)

Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com <http://www.fastlanesw.com> 
http://blog.fastlanesw.com <http://blog.fastlanesw.com> 

Tracy Spratt wrote:
> Yes that example in that other reply will show you how to do this, but
I
> want to make a key idea very clear.
>
> 
>
> When working with data, one never (almost) "loops over the DataGrid".
> One always works with the underlying dataProvider. This is because
Flex
> only creates the visible rows. When you scroll, or change the data,
the
> data from the underlying dataProvider item is assigned to the
> itemRenderer, and the renderer must use that data to update its UI.
>
> 
>
> In your case, the itemRender must set the CheckBox.selected property
> from a value in the dataProvider item.
>
> 
>
> Google "Harui itemRenderer" to find a full discussion and many
examples.
>
> 
>
> Tracy
>
> 
>
> 
>
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of p_repetti
> Sent: Friday, March 21, 2008 7:16 AM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Select all checkboxes in datagrid with a single
> click
>
> 
>
>
> Hello
>
> I have created a DataGrid component whose last column is
rendered/edited
> with a checkbox. This checks whether the row data will be sent to the
> server
> or not.
> Rather than forcing the user to check all of the rows manually, I have
a
> "Select All" button which commands the selection of all the checkboxes
> in
> that column. 
> My problem is that I can't write the code to implement the selection.
It
> is
> AS code most likely, but I could not find an example going through
> docs/forums/whatever.
> How do I loop over the DataGridColumn object to get the CheckBox
> instances ?
>
> Can anyone point me to useful examples/references ?
>
> Thanks
> 

 



Re: [flexcoders] Select all checkboxes in datagrid with a single click

2008-03-21 Thread Scott Melby
Tracy -

Not sure if you are referring to my sample code.  But, just in case you 
are... That code *does* update the underlying data provider.  It simply 
does it generically using ICollectionView and IViewCursor.  This is not 
looping over the renderers afaik.  If it is, I'd sure like to know... 
cuz I wouldn't recommend doing that either :)

Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com
http://blog.fastlanesw.com



Tracy Spratt wrote:
> Yes that example in that other reply will show you how to do this, but I
> want to make a key idea very clear.
>
>  
>
> When working with data, one never (almost) "loops over the DataGrid".
> One always works with the underlying dataProvider.  This is because Flex
> only creates the visible rows.  When you scroll, or change the data, the
> data from the underlying dataProvider item is assigned to the
> itemRenderer, and the renderer must use that data to update its UI.
>
>  
>
> In your case, the itemRender must set the CheckBox.selected property
> from a value in the dataProvider item.
>
>  
>
> Google "Harui itemRenderer" to find a full discussion and many examples.
>
>  
>
> Tracy
>
>  
>
> 
>
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of p_repetti
> Sent: Friday, March 21, 2008 7:16 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Select all checkboxes in datagrid with a single
> click
>
>  
>
>
> Hello
>
> I have created a DataGrid component whose last column is rendered/edited
> with a checkbox. This checks whether the row data will be sent to the
> server
> or not.
> Rather than forcing the user to check all of the rows manually, I have a
> "Select All" button which commands the selection of all the checkboxes
> in
> that column. 
> My problem is that I can't write the code to implement the selection. It
> is
> AS code most likely, but I could not find an example going through
> docs/forums/whatever.
> How do I loop over the DataGridColumn object to get the CheckBox
> instances ?
>
> Can anyone point me to useful examples/references ?
>
> Thanks
>   



RE: [flexcoders] Select all checkboxes in datagrid with a single click

2008-03-21 Thread p_repetti

Randy,

that'd be exactly the example I need, looking at the swf demo. Unfortunately
I can't download the code, there's something wrong with the link.

Pier


You might want to check this:
 
HYPERLINK
"http://deepuverma.wordpress.com/2008/01/10/datagrid-headerrenderer-checkbox
-to-select-checkboxes-in-the-row/"http://deepuverma.wordpress.com/2008/01/10
/datagrid-headerrenderer-checkbox-to-select-checkboxes-in-the-row/
 
~randy


   _  

-- 
View this message in context: 
http://www.nabble.com/Select-all-checkboxes-in-datagrid-with-a-single-click-tp16196734p16201277.html
Sent from the FlexCoders mailing list archive at Nabble.com.



RE: [flexcoders] Select all checkboxes in datagrid with a single click

2008-03-21 Thread Tracy Spratt
Yes that example in that other reply will show you how to do this, but I
want to make a key idea very clear.

 

When working with data, one never (almost) "loops over the DataGrid".
One always works with the underlying dataProvider.  This is because Flex
only creates the visible rows.  When you scroll, or change the data, the
data from the underlying dataProvider item is assigned to the
itemRenderer, and the renderer must use that data to update its UI.

 

In your case, the itemRender must set the CheckBox.selected property
from a value in the dataProvider item.

 

Google "Harui itemRenderer" to find a full discussion and many examples.

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of p_repetti
Sent: Friday, March 21, 2008 7:16 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Select all checkboxes in datagrid with a single
click

 


Hello

I have created a DataGrid component whose last column is rendered/edited
with a checkbox. This checks whether the row data will be sent to the
server
or not.
Rather than forcing the user to check all of the rows manually, I have a
"Select All" button which commands the selection of all the checkboxes
in
that column. 
My problem is that I can't write the code to implement the selection. It
is
AS code most likely, but I could not find an example going through
docs/forums/whatever.
How do I loop over the DataGridColumn object to get the CheckBox
instances ?

Can anyone point me to useful examples/references ?

Thanks
-- 
View this message in context:
http://www.nabble.com/Select-all-checkboxes-in-datagrid-with-a-single-cl
ick-tp16196734p16196734.html
 
Sent from the FlexCoders mailing list archive at Nabble.com.

 



Re: [flexcoders] Select all checkboxes in datagrid with a single click

2008-03-21 Thread p_repetti

Many thanks Scott, 

I had forgotten the MVC rule "work on the data model".
Well, my grid is bound to an XML stored in mySource:XMLListCollection, so
your code becomes:

private  function selectAll(selected:Boolean):void
{
   for each(var item:XML in mySource)
   {
   [EMAIL PROTECTED] = selected;
   }

   myGrid.invalidateList();
}

and it works pretty well.
The problem is that invalidateList() does not work, i.e. the grid is not
refreshed.

What could the problem be ?



Scott Melby-3 wrote:
> 
> You should be able to just set the property of the objects in your data 
> provider that the checkboxes are rendering.  For example, if your grid 
> is bound to an array of objects of type MyClass that are stored in 
> mySourceArray:Array then this would do it.
> 
> private  function selectAll(selected:Boolean):void
> {
>for each(var item:MyClass in mySourceArray)
>{
>item.selected = selected;
>}
> 
>myGrid.invalidateList();
> }
> 
> 
> 
> hth
> Scott
> 
> Scott Melby
> Founder, Fast Lane Software LLC
> http://www.fastlanesw.com
> http://blog.fastlanesw.com
> 
> 
> 
> p_repetti wrote:
>> Hello
>>
>> I have created a DataGrid component whose last column is rendered/edited
>> with a checkbox. This checks whether the row data will be sent to the
>> server
>> or not.
>> Rather than forcing the user to check all of the rows manually, I have a
>> "Select All" button which commands the selection of all the checkboxes in
>> that column. 
>> My problem is that I can't write the code to implement the selection. It
>> is
>> AS code most likely, but I could not find an example going through
>> docs/forums/whatever.
>> How do I loop over the DataGridColumn object to get the CheckBox
>> instances ?
>>
>> Can anyone point me to useful examples/references ?
>>
>> Thanks
>>   
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Select-all-checkboxes-in-datagrid-with-a-single-click-tp16196734p16198564.html
Sent from the FlexCoders mailing list archive at Nabble.com.



RE: [flexcoders] Select all checkboxes in datagrid with a single click

2008-03-21 Thread Randy Martin
You might want to check this:
 
HYPERLINK
"http://deepuverma.wordpress.com/2008/01/10/datagrid-headerrenderer-checkbox
-to-select-checkboxes-in-the-row/"http://deepuverma.wordpress.com/2008/01/10
/datagrid-headerrenderer-checkbox-to-select-checkboxes-in-the-row/
 
~randy


   _  

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of p_repetti
Sent: Friday, March 21, 2008 6:16 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Select all checkboxes in datagrid with a single click




Hello

I have created a DataGrid component whose last column is rendered/edited
with a checkbox. This checks whether the row data will be sent to the server
or not.
Rather than forcing the user to check all of the rows manually, I have a
"Select All" button which commands the selection of all the checkboxes in
that column. 
My problem is that I can't write the code to implement the selection. It is
AS code most likely, but I could not find an example going through
docs/forums/-whatever.
How do I loop over the DataGridColumn object to get the CheckBox instances ?

Can anyone point me to useful examples/references ?

Thanks
-- 
View this message in context: HYPERLINK
"http://www.nabble.com/Select-all-checkboxes-in-datagrid-with-a-single-click
-tp16196734p16196734.html"http://www.nabble.-com/Select--all-checkboxes--in-
datagrid--with-a-single--click-tp16196734-p16196734.-html
Sent from the FlexCoders mailing list archive at Nabble.com.



 


No virus found in this outgoing message.
Checked by AVG. 
Version: 7.5.519 / Virus Database: 269.21.8/1337 - Release Date: 3/20/2008
8:10 PM
 


Re: [flexcoders] Select all checkboxes in datagrid with a single click

2008-03-21 Thread Scott Melby
You should be able to just set the property of the objects in your data 
provider that the checkboxes are rendering.  For example, if your grid 
is bound to an array of objects of type MyClass that are stored in 
mySourceArray:Array then this would do it.

private  function selectAll(selected:Boolean):void
{
   for each(var item:MyClass in mySourceArray)
   {
   item.selected = selected;
   }

   myGrid.invalidateList();
}

If you need to be very generic and do it for any grid... then you would 
need to do something like the following.  Note: the code below was 
created in this email and has not be compiled, etc.  But, it should get 
you close :)

private function selectAllInGrid(grid:DataGrid, selected:Boolean, 
selectedField:String):void
{
var view:ICollectionView = ICollectionView(grid.dataProvider);
var cursor:IViewCursor = view.createCursor();
while(cursor.afterLast() == false)
{
   var obj:Object = cursor.current;
   if(obj.hasOwnProperty(selectedField))
   {
  obj[selectedField] = selected;
   }
   else
   {
   trace("Items in the grid do not appear to have property " + 
selectedField);
   } 
}
grid.invalidateList();
}


hth
Scott

Scott Melby
Founder, Fast Lane Software LLC
http://www.fastlanesw.com
http://blog.fastlanesw.com



p_repetti wrote:
> Hello
>
> I have created a DataGrid component whose last column is rendered/edited
> with a checkbox. This checks whether the row data will be sent to the server
> or not.
> Rather than forcing the user to check all of the rows manually, I have a
> "Select All" button which commands the selection of all the checkboxes in
> that column. 
> My problem is that I can't write the code to implement the selection. It is
> AS code most likely, but I could not find an example going through
> docs/forums/whatever.
> How do I loop over the DataGridColumn object to get the CheckBox instances ?
>
> Can anyone point me to useful examples/references ?
>
> Thanks
>