Flex :: Setting The Correct Sort Function At Runtime?
Aug 27, 2009
Using Flex 3.2, I have a object which extends a TitleWindow. In this TitleWindow I have an AdvancedDataGrid.
On creation of this object, I pass it 2 lists, one full of data to display, and the other I pass an array of column definitions. This allows me to, at runtime, create the correct columns and define the correct display attributes for each column (e.g. booleans will show up as checkboxes, and dates are formatted in a specific format (coming in from an XML feed in a variety of STRING formats where nulls are a possibility)
The problem is that the default sort, being based on string, doesn't work 100% of the time and even when the format is one that would be sorted nicely, it fails when nulls are involved.
The above problem would be easily solved using a sortCompareFunction, but the fact is when you set the sortCompareFunction of the column, it seems to require you to hardcode in the column name into the function.
for reference here's the function I'm using to create the columns:
private function setupGrid():void
{
var localcols:Array = new Array();
[Code].....
View 3 Replies
Similar Posts:
Sep 8, 2011
I have a spark DataGrid component with several columns and I want to have my application default to descending order on the first column in the DataGrid. I would like to use the built-in default sort that occurs when clicking the top header once. I have no need to sort the ArrayCollection I'm working with or change what the comparators are.I also want any user-generated sorting such as clicking on a different column's header to override the default sorting.
View 1 Replies
Oct 17, 2010
Anyone know how to change a single instance of an item renderer for a Flex tree item at runtime? To reiterate, I'm not trying to change the entire tree's item renderer like this:tree.itemRenderer = new ClassFactory(ItemRenderer2);I'm trying to change the item renderer of a single tree item like this (the following code does not work):tree.selectedItem.itemRenderer = new ClassFactory(ItemRenderer2);To put it more simply, does anyone know how to reference an instance of an item renderer and set it to a new item renderer class? I've tried using the Tree's itemToItemRenderer() method with no success.
View 1 Replies
Mar 5, 2010
Here is a website that needs a sort function to sort the video by Last name. [URL] I would like to have a link that popped up videos sorted by last name. Please take a look at the following site for an example. [URL] When you click on seconds in the menu below, it opens a pop-up window that sort the videos in a certain way. If you are willing to,I will give you the source file of what it currently has on [URL]
View 1 Replies
Apr 9, 2009
I have an exam which pulls in questions from an XML file and to indicate what the correct answer is you would indicate in the XML as such:
[Code]...
There is one question, that is structured so there are two right answers, but when I add correct="true" to both answers I want as right only one is calculated correctly in the scoring. I thinking I need to make an adjustment in the code that pulls in the XML, but not sure where. Here is the AS code.
[Code]...
View 11 Replies
Mar 3, 2010
I want to pass an optional data parameter to some callbacks, but only to callbacks that support a single parameter; right now, I have a moderately-sized code base of callbacks that cannot accept a parameter at all. How can I check what parameters a Function object supports?
View 3 Replies
Jun 30, 2011
When I get a collection back from the service tier, I create an ArrayCollection and apply a sort. When I add an item to the collection later on, the sort is still in place? It seems to be the case. I thought I was only sorting it once, not applying a sort that will stick??Here is the method for adding an item:
private function onAddNewClick():void
{
var fileTemplate:FileTemplateDetailDTO = new FileTemplateDetailDTO();
[code].....
View 4 Replies
Mar 14, 2011
i have a class and trace its type with flash.utils.describeType(this)
class Data extends EventDispatcher
{
public function Data()
[Code]....
Is it possible to override this information e.g type.@isDynamic, as well as extendsClass.@type, at runtime? without bytecode?
View 5 Replies
Aug 27, 2010
Summary: I don't quite understand how the import/export URLs for symbols in a runtime library work. I can't figure out how I can set them so that the runtime library will be properly loaded and accessible for other swfs to import from, if I want it to work both in a local environment (on my harddrive), and from a remote environment (on a web page).
Relative URLs seem to work great for the hard-drive case, but fail for the web page. Is there a magic way to set the relative URL to work from the web too? And/or, is there some way of manually loading up the RSL at runtime and making the importing swfs import from that loaded copy, rather than having Flash doing it behind the scenes based on the import URL set in the symbol? Following is a longish description of what I'm trying to do, and why... I'm trying to figure out if we can use RSLs to contain common UI controls for our next project. I'm running into an organizational issue that I can't quite figure out - how to get the RSLs to work in both a local development/debugging environment, and on a production web environment, with the same exporting/importing URLs.
Here's what my setup would look like. Say I have a main application main.swf, an RSL lib.swf, and a UI module dialog.swf. Main.swf loads or embeds dialog.swf. lib.swf exports some symbols that dialog.swf imports. On a local development environment, these swfs are found in folders like so:
[Code]...
View 1 Replies
Aug 26, 2010
I'm trying to figure out if we can use RSLs to contain common UI controls for our next project. I'm running into an organizational issue that I can't quite figure out - how to get the RSLs to work in both a local development/debugging environment, and on a production web environment, with the same exporting/importing URLs.
Here's what my setup would look like. Say I have a main application main.swf, an RSL lib.swf, and a UI module dialog.swf.
Main.swf loads or embeds dialog.swf. lib.swf exports some symbols that dialog.swf imports.
On a local development environment, these swfs are found in folders like so:
[URL]
Here is the problem. If I set the export/import url for symbols in lib.swf to "assets/lib/lib.swf" (relative to the location of main.swf), the runtime library gets loaded fine in the local environment. But in the web environment, it does not load - the player just shows the "..." graphic indicating it is trying to load.
Alternatively, I can use "http:/myapp.com/assets/lib/lib.swf" as the export/import url. Now, it will work in the web environment. However, in the local environment, dialog.swf will load symbols from the lib.swf that is out on the web, not the one that is local. But I need it to load from the local version, so that designers can muck about with the assets and see the results locally before publishing to the web.
Is there some alternative way to set up the swf's, or way to set the URLs, or some other hoop I can jump through that will make the RSL load properly in either environment without having to manually change URLs all the time?
(Details: I am using Flash Builder 4, CS 5, Action Script 3, Flash Player 10... No Flex! My example omits some details from my actual setup, such as the fact that we are using a preloader to load the main application, and a php script on the web page to start the preloader.)
View 4 Replies
Nov 26, 2003
Given an XML file similar to this:
Code:
<class>
<student>
<last_name>Smith</last_name>[code]....
Is there a way or a function to sort this XML via last name?
View 2 Replies
Feb 9, 2004
the sort() function for arrays in Flash MX. How efficient is it? I am currently developing a flash application that will need to read in hundreds of records from a database and sort them.speed is crucial. Which is better? to use the built in sort() function or to create my own shell-sort?
View 3 Replies
Mar 25, 2005
I need help with page "Thumbs" (as first frame), page "List" (as second frame) and Image gallery (as third and base). So, every frame have one own XML file...When you choose some thumb or list line, you must came to this image in the gallery. Easy, sure.. but i don't know what Function exactly i need to use.It's one flash move, hence it doesn't work with getURL or loadMovie...Some exemple with 3 separate pages here: yuri.fr
View 1 Replies
Jul 9, 2010
Basically I have created a custom sort function to use with sort(); inside an Array object and I have traced the amount of times each sort() has called customSortFunction. Apparently it keeps changing the amount of times it is called which has seemed to cause problems for me.I am using this to sort Sprite obects on the stage. I am working with an isometric grid and need to make sure everything is sorted based on y and if two objects are on the same tile (tile hover and avatar etc) then it sorts them as well.
However it seems that when I have some objects in a certain position, the customSortFunction isn't called to sort every single item. The case I am facing just now is it sorts every item, but leaves 2 unsorted. I have traced and debugged and it is definitely not calling customSortFunction enough times.
View 15 Replies
Nov 17, 2011
There appears to be a problem with the sort function when sorting the array contains several elements that are equal. I tried to illustrate this in the simplest form below:
[Code]....
View 5 Replies
Dec 6, 2006
I am making a matching game for my company. I created an xml document to load in flash of medications and their descriptions. I used a dropdown menu component to load the categories the user can choose from and randomly load a med from that category. If they match it correctly, I want that item to disappear from the list to randomly load in that category.
However, the way it is working is...it does not randomly load a med (it loads the first item in the list [0]), it does not keep looping through the categories, nor does it remove an item from the list. I imagine if I can get direction to properly/initially load and randomize the data, that I can figure out the rest from there. I have been working on this for a long time...and I am stumped.
var Answer:Array;
var checkAnswer:Array;
//------------------Load the XML,populate the combo box and load med info into categories---------------------------------
import mx.utils.Delegate;
[code].....
View 1 Replies
Sep 19, 2009
In actions in my .fla file I create a new object of a class (addChild) which is in an separate .as file. Now, in my .as file I want to call a function in the .fla file. This should be the parent right? So, I try parent.correct(); which does not work. I get the error #1061 (call to a possibly undefined method). However, when I do this:
var par:* = parent;
par.correct();
Everything works. Why is this?
View 3 Replies
Nov 27, 2010
I have an array that is structured like so.
[Code]....
Normally, I'd just like to sort the array alphabetically using the name field, which is easy enough using the following code. However, I'd like to create a radio button called 'loadedRadioButton' and when it's click on, I'd like to sort the array on the loaded value first(any items with loaded=true should be at the top, sorted alphabetically), then afterwards, any other items with loaded=false, sorted alphabetically should follow afterwards, how can I do it?
View 0 Replies
May 11, 2011
Here are the strings this array can contain (in the correct order):
'recipients,' 'columnSelector,' 'headerImageLink,' 'title,' 'mainText,' 'text,' 'bodyImage'
Now, to sort them, I obviously don't want to do something like this:
if( a == 'columnSelector' && b == 'headerImageLink' ) return -1;
else if( a == 'columnSelector' && b == 'title' ) return -1;
else if( a == 'columnSelector' && b == 'mainText' ) return -1;
So that brings up an interesting thing. I know you can optimize the above some using something like this:
if( a == 'columnSelector' || a == 'bodyImage' ) return -1;
This would get the last two, but lately I have just wanted community input on issues I have had in the past. So the question is, what is the best way to write a custom sort, using a relatively random order (not alphabetical, etc)?
View 1 Replies
Dec 30, 2009
I'm trying to get the depths of all the blocks to be at the correct levels at the correct times so that the 3d effect is maintained. I've tried many things, but have had little success. All the instances of the blocks are stored in an array, but since it's adding them in accordance with when they're added to the stage, it doesn't help me locate them to swap depths. Is there a way to arrange them by location on the board?
View 4 Replies
Aug 3, 2009
After applying a numeric sort to my dataprovider(Array Collection), I can not reorder the items via a tilelist. Do I need to remove the sort from the arrayCollection. If so, is it just a case of setting collection.sort = null ?
var sortField:SortField=new SortField();
sortField.name="order";
sortField.numeric=true;
var sort:Sort=new Sort();
sort.fields=[sortField];
View 3 Replies
Sep 19, 2009
I need to be able to sort the items of a combobox so they will be in alphabetical order. how would I do this?
View 2 Replies
Feb 13, 2011
Im loading tabs for an accordion control at runtime. The number of tabs is determined by the role of the user. Each tab comes from a module so the load time is variable. As a result the list order changes every time the app is run.Is there a practical way to sort the tabs as each new tab is loaded?
View 1 Replies
Mar 15, 2011
I'm making an application where I display an AdvanvedDataGrid with one column with dates(in format DD/MM/YYYY) and another with datetimes (in format HH:MM). I'd like to sort dates according with the datetimes as well(just clicking in the header of the column), there is an examplen of the expected behaviour:
02/02/2011 | 10:42
03/02/2011 | 09:45
02/02/2011 | 11:45
03/02/2011 | 11:30
[Code]....
_currentDatosBusqueda is an arraycollection I receive from the Server (with the correct format of dates and datetime).
View 2 Replies
Mar 24, 2011
I am sorting xmllist profilexml. In the list dates and months are sorted using SortField. It is sorting up to September month. After that Oct, Nov, and Dec are coming and displaying on the top in the datagrid.
finalList = new XMLListCollection(profileXml);
var sortL:Sort = new Sort();
sortL.fields = [new SortField("startDate", true)];
[Code]....
<startDate>2/15/2011</startDate> as per my understanding it is sorting until 0-9 numeric fields only. Is there anything I need to add in this code for numeric sorting?
View 1 Replies
Feb 24, 2012
I want to sort Arraycollection in fieldName as ascending...heres my code and i wan to know whether its rite.
public static function arrayCollectionSort(ar:ArrayCollection, fieldName:String, isNumeric:Boolean):void
{var dataSortField:SortField = new SortField();
[code].....
View 3 Replies
Aug 13, 2009
next to the header of an advancedDataGrid you see a number. This number stays grey no matter what i do. I Already searched 1 hour to find the solution.
View 1 Replies
Jun 11, 2010
I have a requirement of sorting the <ename> in the XML with in the branch. The XML goes like this:
<company>
<branch>
<name>finance</name>
[code]......
View 1 Replies
Nov 13, 2010
I want to sort items in the datagrid alphabetically by name.The order should be:
1) The name should first check for upeercase of the name if it is not then it should look for lowercase for the same letter alphabetically.
For example : if i have array of items say{Apple,boy,ant,Bat) then after sorting the list shld be
Apple
ant
Bat
boy
View 2 Replies
Feb 1, 2011
I#m looking for a solution to sort all grouped colums in advancedDatagrid. It should be the same behavior like clicking in a columns head. i'm not looking for a solution to sort the fields IN a the grouping. There is working solution named compareFunction. But I'm not able to sort the two rows in my picture by column "Einnahmen". Sorry for the german word.
View 4 Replies