Re: [flexcoders] Problem in sorting XMLList collection as a dataProvider for the list

2009-03-05 Thread crazy developer
Hi Thanks for replying
What does we mean by custom sort compare function, Can we provide any
examples of both sort and sort compare functions or little more details
about what and how does we do that?
Thanks much fro your help



On Thu, Mar 5, 2009 at 11:24 AM, Alex Harui  wrote:

>If you have a labelfunction, you’ll probably need a custom sortcompare
> function
>
>
>
> Alex Harui
>
> Flex SDK Developer
>
> Adobe Systems Inc. <http://www.adobe.com/>
>
> Blog: http://blogs.adobe.com/aharui
>
>
>
> *From:* flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] *On
> Behalf Of *anuj181
> *Sent:* Wednesday, March 04, 2009 3:51 PM
> *To:* flexcoders@yahoogroups.com
> *Subject:* [flexcoders] Problem in sorting XMLList collection as a
> dataProvider for the list
>
>
>
> Hi Guys
>
> I am trying to sort the xmllist collection which is the dataprovider for
> the list. As the implementation of name-value pairs, i am displaying the
> entries in form of string in List and would like to sort all the data
> displayed in the List alphabetically, I am making a call through amfphp call
> to grab data from backend and populate XMLListCollection but now I need to
> sort the data in the list. Below is the code,Can anyone please help me where
> I am messing things up. Also please let me know if there is any question
> regarding the code and if there is better way of doing it.
>
> Thanks
>
> /**CODE/
>
> 
>  fault="getListFault(event);"/>
> 
>
> [Bindable] private var entriesXmlListFull:XMLList;
> [Bindable] private var entriesXmlCollection:XMLListCollection;
>
>
> public function getListHandler(event:ResultEvent):void
> {
>
> entriesXmlListFull = XML(event.result).device;
> populateEntries();
> }
> private function getListFault(event:FaultEvent):void
> {
> Alert.Show("Error retreiving Data");
> }
>
> //Displaying names need to be displayed in the List box
> private function entriesLabelFunc(item:Object):String
> {
> var xmlItem:XML = item as XML;
>
> return xmlItem..attribute.(@name=="friendlyname");
> }
>
> //Populating List with XML Objects
> private function populateEntries():void
> {
> entriesXmlCollection = new XMLListCollection();
>
> for each(var item:XML in entriesXmlListFull)
> {
>
> var friendlyName:String = item..attribute.(@name=="friendlyname");
> //Only add camera type
> if ( !recordValue && hasFriendlyName && (itemType.toUpperCase() ==
> "CAMERA") )
> {
> entriesXmlCollection.addItem(item);
> }
> }
>
> //Calling Sort on XMLList collection
> entriesXmlCollection.sort = sortList;
> entriesXmlCollection.refresh();
>
>
> }
>
>
> 
> 
> 
> 
> 
>
>  labelFunction="entriesLabelFunc"/>
>
>   
>


RE: [flexcoders] Problem in sorting XMLList collection as a dataProvider for the list

2009-03-05 Thread Alex Harui
If you have a labelfunction, you'll probably need a custom sortcompare function

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of anuj181
Sent: Wednesday, March 04, 2009 3:51 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Problem in sorting XMLList collection as a dataProvider 
for the list


Hi Guys
I am trying to sort the xmllist collection which is the dataprovider for the 
list. As the implementation of name-value pairs, i am displaying the entries in 
form of string in List and would like to sort all the data displayed in the 
List alphabetically, I am making a call through amfphp call to grab data from 
backend and populate XMLListCollection but now I need to sort the data in the 
list. Below is the code,Can anyone please help me where I am messing things up. 
Also please let me know if there is any question regarding the code and if 
there is better way of doing it.

Thanks

/**CODE/





[Bindable] private var entriesXmlListFull:XMLList;
[Bindable] private var entriesXmlCollection:XMLListCollection;


public function getListHandler(event:ResultEvent):void
{

entriesXmlListFull = XML(event.result).device;
populateEntries();
}
private function getListFault(event:FaultEvent):void
{
Alert.Show("Error retreiving Data");
}

//Displaying names need to be displayed in the List box
private function entriesLabelFunc(item:Object):String
{
var xmlItem:XML = item as XML;

return xmlItem..attribute.(@name=="friendlyname");
}

//Populating List with XML Objects
private function populateEntries():void
{
entriesXmlCollection = new XMLListCollection();

for each(var item:XML in entriesXmlListFull)
{

var friendlyName:String = item..attribute.(@name=="friendlyname");
//Only add camera type
if ( !recordValue && hasFriendlyName && (itemType.toUpperCase() == "CAMERA") )
{
entriesXmlCollection.addItem(item);
}
}

//Calling Sort on XMLList collection
entriesXmlCollection.sort = sortList;
entriesXmlCollection.refresh();


}












RE: [flexcoders] Problem in sorting XMLList collection as a dataProvider for the list

2009-03-05 Thread Tracy Spratt
I would use a sort function, so I could debug any problems.

 

I'd also suggest an e4x expression instead of the loop.

 

Tracy

 

  _  

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
Behalf Of anuj181
Sent: Wednesday, March 04, 2009 6:51 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Problem in sorting XMLList collection as a
dataProvider for the list

 

Hi Guys
I am trying to sort the xmllist collection which is the dataprovider for the
list. As the implementation of name-value pairs, i am displaying the entries
in form of string in List and would like to sort all the data displayed in
the List alphabetically, I am making a call through amfphp call to grab data
from backend and populate XMLListCollection but now I need to sort the data
in the list. Below is the code,Can anyone please help me where I am messing
things up. Also please let me know if there is any question regarding the
code and if there is better way of doing it.

Thanks

/**CODE/

 
 


[Bindable] private var entriesXmlListFull:XMLList;
[Bindable] private var entriesXmlCollection:XMLListCollection;


public function getListHandler(event:ResultEvent):void
{ 

entriesXmlListFull = XML(event.result).device;
populateEntries();
}
private function getListFault(event:FaultEvent):void
{
Alert.Show("Error retreiving Data");
}

//Displaying names need to be displayed in the List box
private function entriesLabelFunc(item:Object):String
{
var xmlItem:XML = item as XML;

return xmlItem..attribute.(@name=="friendlyname");
}

//Populating List with XML Objects
private function populateEntries():void
{
entriesXmlCollection = new XMLListCollection(); 

for each(var item:XML in entriesXmlListFull)
{

var friendlyName:String = item..attribute.(@name=="friendlyname");
//Only add camera type
if ( !recordValue && hasFriendlyName && (itemType.toUpperCase() == "CAMERA")
)
{
entriesXmlCollection.addItem(item);
}
}

//Calling Sort on XMLList collection 
entriesXmlCollection.sort = sortList;
entriesXmlCollection.refresh(); 


}














[flexcoders] Problem in sorting XMLList collection as a dataProvider for the list

2009-03-05 Thread anuj181
Hi Guys
I am trying to sort the xmllist collection which is the dataprovider for the 
list. As the implementation of name-value pairs, i am displaying the entries in 
form of string in List and would like to sort all the data displayed in the 
List alphabetically, I am making a call through amfphp call to grab data from 
backend and populate XMLListCollection but now I need to sort the data in the 
list. Below is the code,Can anyone please help me where I am messing things up. 
Also please let me know if there is any question regarding the code and if 
there is better way of doing it.

Thanks

/**CODE/

  




[Bindable] private var entriesXmlListFull:XMLList;
[Bindable] private var entriesXmlCollection:XMLListCollection;


public function getListHandler(event:ResultEvent):void
{   

entriesXmlListFull = XML(event.result).device;
populateEntries();
}
private function getListFault(event:FaultEvent):void
{
Alert.Show("Error retreiving Data");
}

//Displaying names need to be displayed in the List box
private function entriesLabelFunc(item:Object):String
{
var xmlItem:XML = item as XML;

return xmlItem..attribute.(@name=="friendlyname");
}

//Populating List with XML Objects
private function populateEntries():void
{
entriesXmlCollection = new XMLListCollection(); 


for each(var item:XML in entriesXmlListFull)
{

var friendlyName:String = 
item..attribute.(@name=="friendlyname");
//Only add camera type
if ( !recordValue && hasFriendlyName && 
(itemType.toUpperCase() == "CAMERA") )
{
entriesXmlCollection.addItem(item);
}
}

//Calling Sort on XMLList collection
entriesXmlCollection.sort = sortList;
entriesXmlCollection.refresh();  


}