RE: [Flashcoders] Datagrid sorting

2007-03-16 Thread Merrill, Jason
>>You should add a listener to the DataGrid

Nah, when you change the dataProvider for a datagrid, the datagrid fires
an event anyway.  

All, I had posted I figured it out on my own, thanks anyway!  Much
appreciated. 

I used:

lobAdmins_dg.dataProvider.sortItemsBy("lob", "ASC");

Odd that there is a sortItemsBy for dataProvider, but a sortOn for
Arrays.  

Jason Merrill
Bank of America  
Global Technology & Operations
Learning & Leadership Development 
eTools & Multimedia Team


 

>>-Original Message-
>>From: [EMAIL PROTECTED] 
>>[mailto:[EMAIL PROTECTED] On Behalf 
>>Of Bojil Vassilev
>>Sent: Thursday, March 15, 2007 4:50 PM
>>To: [email protected]
>>Subject: Re: [Flashcoders] Datagrid sorting
>>
>>You should add a listener to the DataGrid and then sort the 
>>dataprovider. Here is a quick example, also sorting both ways 
>>Asc<>Desc (keeping track if a column is sorted one way and 
>>sorting it the other way next time)
>>
>>myDataGrid.addColumn("Product");
>>myDataGrid.addColumn("Quality");
>>myDataGrid.addColumn("Quantity");
>>
>>var myDP:Array = [];
>>myDP.push({Product:"abc", Quality:145, Quantity:7}); 
>>myDP.push({Product:"bcd", Quality:79, Quantity:0}); 
>>myDP.push({Product:"def", Quality:300, Quantity:24}); 
>>myDP.push({Product:"efg", Quality:138, Quantity:10});
>>
>>myDataGrid.dataProvider = myDP;
>>
>>var productSorted:Boolean = true;
>>var qualitySorted:Boolean = true;
>>var quantitySorted:Boolean = true;
>>
>>// Create listener object for DataGrid.
>>var listener_obj:Object = new Object();
>>listener_obj.headerRelease = function(evt_obj:Object) {  
>>switch (evt_obj.target.columns[evt_obj.columnIndex].columnName)
>> {
>>case "Product" :
>>if(productSorted) myDP.sortOn("Product", Array.CASEINSENSITIVE);
>>else myDP.sortOn("Product", Array.DESCENDING | 
>>Array.CASEINSENSITIVE);
>>productSorted = !productSorted;
>>break;
>>case "Quality" :
>>if(qualitySorted) myDP.sortOn("Quality", Array.NUMERIC);
>>else myDP.sortOn("Quality", Array.DESCENDING | Array.NUMERIC);
>>qualitySorted = !qualitySorted;
>>break;
>>case "Quantity" :
>>if(quantitySorted) myDP.sortOn("Quantity", Array.NUMERIC);
>>else myDP.sortOn("Quantity", Array.DESCENDING | Array.NUMERIC);
>>quantitySorted = !quantitySorted;
>>break;
>> }
>>};
>>
>>// Add listener to DataGrid.
>>myDataGrid.addEventListener("headerRelease", listener_obj);
>>
>>
>>
>>Merrill, Jason wrote:
>>> Need some help on sorting a datagrid by a particular collumn. Right 
>>> now, it's sorting alphabetically by data in the second 
>>collumn instead 
>>> of the first.  I tried sorting the dataprovider first with 
>>the array 
>>> sort methods, but they didn't work and the help docs indicate those 
>>> array sorting methods don't work on associative arrays.
>>>
>>> I have tried:
>>>
>>> lobAdmins_dg.dataProvider.sortOn("lob", Array.DESCENDING);
>>>
>>> and also with the DataSetIterator:
>>>
>>> lobAdmins_dg.dataProvider.addSort("lobSort", "lob", 
>>> DataSetIterator.Descending);
>>>
>>> and:
>>>
>>> lobAdmins_dg.dataProvider.addSort("lobSort", ["lob"], 
>>> DataSetIterator.Descending);
>>>
>>> and then setting the dataprovider to the datagrid. (lob is 
>>the name of 
>>> the datagrid collumn and also the property/field in the 
>>dataprovider I 
>>> want to sort on alphabetically.
>>>  
>>> Also searched help docs, Adobe and Google but no luck.  Any ideas?
>>>
>>> Jason Merrill
>>> Bank of America
>>> Global Technology & Operations
>>> Learning & Leadership Development
>>> eTools & Multimedia Team
>>>
>>>
>>> ___
>>> [email protected]
>>> To change your subscription options or search the archive:
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>> Brought to you by Fig Leaf Software
>>> Premier Authorized Adobe Consulting and Training 
>>> http://www.figleaf.com http://training.figleaf.com
>>>
>>>   
>>
>>___
>>[email protected]
>>To change your subscription options or search the archive:
>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>>Brought to you by Fig Leaf Software
>>Premier Authorized Adobe Consulting and Training 
>>http://www.figleaf.com http://training.figleaf.com
>>
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Datagrid sorting

2007-03-15 Thread Bojil Vassilev
You should add a listener to the DataGrid and then sort the 
dataprovider. Here is a quick example, also sorting both ways Asc<>Desc 
(keeping track if a column is sorted one way and sorting it the other 
way next time)


myDataGrid.addColumn("Product");
myDataGrid.addColumn("Quality");
myDataGrid.addColumn("Quantity");

var myDP:Array = [];
myDP.push({Product:"abc", Quality:145, Quantity:7});
myDP.push({Product:"bcd", Quality:79, Quantity:0});
myDP.push({Product:"def", Quality:300, Quantity:24});
myDP.push({Product:"efg", Quality:138, Quantity:10});

myDataGrid.dataProvider = myDP;

var productSorted:Boolean = true;
var qualitySorted:Boolean = true;
var quantitySorted:Boolean = true;

// Create listener object for DataGrid.
var listener_obj:Object = new Object();
listener_obj.headerRelease = function(evt_obj:Object)
{
switch (evt_obj.target.columns[evt_obj.columnIndex].columnName)
{
   case "Product" :
   if(productSorted) myDP.sortOn("Product", Array.CASEINSENSITIVE);
   else myDP.sortOn("Product", Array.DESCENDING | Array.CASEINSENSITIVE);
   productSorted = !productSorted;
   break;
   case "Quality" :
   if(qualitySorted) myDP.sortOn("Quality", Array.NUMERIC);
   else myDP.sortOn("Quality", Array.DESCENDING | Array.NUMERIC);
   qualitySorted = !qualitySorted;
   break;
   case "Quantity" :
   if(quantitySorted) myDP.sortOn("Quantity", Array.NUMERIC);
   else myDP.sortOn("Quantity", Array.DESCENDING | Array.NUMERIC);
   quantitySorted = !quantitySorted;
   break;
}
};

// Add listener to DataGrid.
myDataGrid.addEventListener("headerRelease", listener_obj);



Merrill, Jason wrote:

Need some help on sorting a datagrid by a particular collumn. Right now,
it's sorting alphabetically by data in the second collumn instead of the
first.  I tried sorting the dataprovider first with the array sort
methods, but they didn't work and the help docs indicate those array
sorting methods don't work on associative arrays.  


I have tried:

lobAdmins_dg.dataProvider.sortOn("lob", Array.DESCENDING);

and also with the DataSetIterator:

lobAdmins_dg.dataProvider.addSort("lobSort", "lob",
DataSetIterator.Descending); 


and:

lobAdmins_dg.dataProvider.addSort("lobSort", ["lob"],
DataSetIterator.Descending); 


and then setting the dataprovider to the datagrid. (lob is the name of
the datagrid collumn and also the property/field in the dataprovider I
want to sort on alphabetically.  
 
Also searched help docs, Adobe and Google but no luck.  Any ideas?


Jason Merrill
Bank of America  
Global Technology & Operations
Learning & Leadership Development 
eTools & Multimedia Team



___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

  


___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Datagrid sorting

2007-03-15 Thread Derek Lords
Can your DataProvider be xml?
I'm not sure the Array sort methods do what you want, they might,  but they're 
probably less efficient than an xml transformation anyway.
 
then you might try sorting the dataSource itself beforehand using  in 
an xsl template?  When you want to reverse the sort, just transform again.
 



Sincerely,

Derek Lords 
 


www.itsimmediate.com phone: 917-579-2367cell: 501-631-3817 [EMAIL PROTECTED] 

"It was a sometime paradox, but now time has given it proof." —Shakespeare

> Date: Thu, 15 Mar 2007 13:16:14 -0400> From: [EMAIL PROTECTED]> To: 
> [email protected]> Subject: [Flashcoders] Datagrid sorting> > 
> Need some help on sorting a datagrid by a particular collumn. Right now,> 
> it's sorting alphabetically by data in the second collumn instead of the> 
> first. I tried sorting the dataprovider first with the array sort> methods, 
> but they didn't work and the help docs indicate those array> sorting methods 
> don't work on associative arrays. > > I have tried:> > 
> lobAdmins_dg.dataProvider.sortOn("lob", Array.DESCENDING);> > and also with 
> the DataSetIterator:> > lobAdmins_dg.dataProvider.addSort("lobSort", "lob",> 
> DataSetIterator.Descending); > > and:> > 
> lobAdmins_dg.dataProvider.addSort("lobSort", ["lob"],> 
> DataSetIterator.Descending); > > and then setting the dataprovider to the 
> datagrid. (lob is the name of> the datagrid collumn and also the 
> property/field in the dataprovider I> want to sort on alphabetically. > > 
> Also searched help docs, Adobe and Google but no luck. Any ideas?> > Jason 
> Merrill> Bank of America > Global Technology & Operations> Learning & 
> Leadership Development > eTools & Multimedia Team> > > 
> ___> 
> [email protected]> To change your subscription options or 
> search the archive:> 
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders> > Brought to you 
> by Fig Leaf Software> Premier Authorized Adobe Consulting and Training> 
> http://www.figleaf.com> 
> http://training.figleaf.com___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


RE: [Flashcoders] Datagrid sorting

2007-03-15 Thread Pete Miller
Is dataProvider.sortOn a proper method?  Do you want
dataProvider.sortItemsBy instead?

P.

>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:flashcoders-
>> [EMAIL PROTECTED] On Behalf Of Merrill, Jason
>> Sent: Thursday, March 15, 2007 1:16 PM
>> To: [email protected]
>> Subject: [Flashcoders] Datagrid sorting
>> 
>> Need some help on sorting a datagrid by a particular collumn. Right
now,
>> it's sorting alphabetically by data in the second collumn instead of
the
>> first.  I tried sorting the dataprovider first with the array sort
>> methods, but they didn't work and the help docs indicate those array
>> sorting methods don't work on associative arrays.
>> 
>> I have tried:
>> 
>>  lobAdmins_dg.dataProvider.sortOn("lob", Array.DESCENDING);
>> 
>> and also with the DataSetIterator:
>> 
>>  lobAdmins_dg.dataProvider.addSort("lobSort", "lob",
>> DataSetIterator.Descending);
>> 
>> and:
>> 
>>  lobAdmins_dg.dataProvider.addSort("lobSort", ["lob"],
>> DataSetIterator.Descending);
>> 
>> and then setting the dataprovider to the datagrid. (lob is the name
of
>> the datagrid collumn and also the property/field in the dataprovider
I
>> want to sort on alphabetically.
>> 
>> Also searched help docs, Adobe and Google but no luck.  Any ideas?
>> 
>> Jason Merrill
>> Bank of America
>> Global Technology & Operations
>> Learning & Leadership Development
>> eTools & Multimedia Team
>> 
>> 
>> ___
>> [email protected]
>> To change your subscription options or search the archive:
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> 
>> Brought to you by Fig Leaf Software
>> Premier Authorized Adobe Consulting and Training
>> http://www.figleaf.com
>> http://training.figleaf.com
___
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com