XML :: Flex Sorting Of ListCollection Sub Elements
Aug 13, 2009
In a Flex webapp, is there an easy way to go about applying a sort to the children of an XML element, based on the children's attributes? Example follows below:
XMLListCollection:
<a anotherProp="ABCDE">
<e prop="AB">1</element>
<e prop="BC">2</element>
</a><a anotherProp="FGEH">
<e prop="HF">3</element>
<e prop="AD">4</element>
<e prop="AC">5</element></a>
I would like to sort the <e> elements, within each <a> element separately, according to their "prop" attribute. My code for generating the array containing the <a> elements is along the lines of:
for each(var node:XML in initialInput:XMLListCollection){
if(node.localName()=="a"){
//I was hoping to be able to sort the <e> children of the node variable here
xmlListCollectionVar.addItem(node);
}}
At the end I would like the <a>'s to remain in their defined order, but their <e> children to be sorted based on the "prop" attribute. So far if I try:
node.children().sort=someSortVar
Where someSortVar has its fields set to:
SortFields("e.@prop",...)
I get an exception about a null value. Any way to convert the children list to XMLListCollection, sort it and integrate it back into the node variable?
View 3 Replies
Similar Posts:
Dec 29, 2010
I am working in flex builder 3 with an XMLListCollection and have run into this (should be simple) parsing snag...The XMLListCollection Data:
<data>
<term name="NUMBERS">
<alt_form name="1"/>
[code]......
View 3 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
Jul 27, 2010
I have several datagrids with changing columns. For the text fields the datagrid's sort function neems to be making a case sensitive compare. eg. the following list sorted would look like this apples strawberries Autos Autos should be with apples but since the capital A is counted differently all capital letters come after. I've found a lot of information on setting a CASEINSENSITIVE flag, but I can't figure out where to do this. The best solution would be one where I can override the default behavior to be case insensitive for all my datagrids and all my compare functions.
View 3 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
Feb 18, 2012
I'm using Flashbuilder 4.6 and can't get sorting of columns in my s:DataGrid to work, clicking on the columns does nothing. Can anyone suggest what is wrong?
[Code]...
View 1 Replies
Oct 21, 2009
Is there any way in Flex where in we can sort an arraycollection based on strings .I have a dataprovider with strings like "Critical" "High" "Medium" "Low" where in I need to sort it in such a way that I need Critical to be displayed on the top and next High , Medium and Low follows.
View 1 Replies
Apr 4, 2011
I have an advancedDataGrid and I would like to sort the adg according one AdvancedDataGridColumn(studyDate) which use strings in format DD/MM /YYYY(I receive like this from the server):But i find another problem, I need to sort the columns of the adg the first time it displays so I used the following function but It doesn't sort from the recent day to old one, I do not know what I can I do cause I set sort.descending= true, any ideas?[code]
View 1 Replies
Sep 26, 2011
I have a one comboBox that I fill as:
for (var key:String in values) {
conns.addItem(key);
}
After that I sorted my ComboBox as:
private function sortConnection():void {
var dataSortField:SortField = new SortField();
dataSortField.name = "data";
dataSortField.numeric = true;
var numericDataSort:Sort = new Sort();
numericDataSort.fields = [dataSortField];
conns.sort = numericDataSort;
conns.refresh();
}
And on finish I want to select item on my specific value in ComboBox. How can I do that? I try:
for (var ii:Number=0; ii<combo.rowCount; ii++) {
var item:String = combo.getChildAt(ii);
if (item == name) {
index = ii;
}}
But does not work. I do not know where I made mistake, and how I can select on specific item in my combobox.
View 2 Replies
Jul 2, 2009
I have a column with 4 fields named : a> Main, b> Forward c> Back d> Link, if I use pre-defined sorting of datagrid with the column names which will be alphabetically, then the order is c>Back b>Forward d> Link a> Main. But, I do not want to sort based on the alphabets. I prefer to sort by names of the column fields. i.e. somehow give priority to each individual column field names. Like pre-define my own order.
View 2 Replies
Dec 12, 2009
I have a datagrid with data like this:
[Code]...
View 1 Replies
Jan 18, 2010
I have a Advanced Datagrid with sorting. I think it is string sorting by default. But i need the sorting in number. How can i achieve the number sorting.for example: i have row numbers like 1 to 100 . i need number sorting like 1,10,100.
View 2 Replies
Aug 25, 2010
I am using in-built sort functionality provided by AdvancedDatagrid.I have multiple columns and suppose I have 10 rows. All 10 rows have the same data in one column.If I sort on that column, then it sorts and the data in other columns which is different is also being sorted (reshuffled).My requirement is if I am sorting on a column with same data, it should not sort the data in other columns.To understand it better, check the link menioned below URL...In the above link mentioned, if you click on region column, other columns like territory or actual will change the values i.e. the rows gets reshuffled.This should not happen as we are sorting on a column which has same values. Does anybody know how this can be handled in Flex 3 for AdvancedDataGrid.
View 1 Replies
Dec 8, 2009
I have an ArrayCollection of Objects. Each Object has the following keys/values:
{date: 2009-12-01, visits=13555, bouceRate=45}
{date: 2009-12-05, visits=46955, bouceRate=45}
{date: 2009-12-06, visits=13685, bouceRate=45}
[code].......
View 3 Replies
Oct 7, 2010
I'm trying to provide some default sorting within the OLAPDataGrid component in Flex. There appears to be a dataCompareFunction on OLAPAttribute, but nothing I do seems to actually trigger calls to that method. Any suggestions around using this method or any others to provide sorting of the dimensions on OLAPDataGrid?
View 2 Replies
Nov 26, 2010
I have an ArrayCollection nested in another one. I need to sort the child collection by a field.
I tried the following code. It works fine for the parent collection, but does nothing for the child one.
// The Data
public class Data
{
public var value:String;
public var otherValue:String;
public var childrenData:ArrayCollection; // An array collection containing Data objects.
}
[Code]...
View 1 Replies
Jun 25, 2011
I have a list which displays votes cast on things in a descending order (=the dataprovider has a sort assigned). The elements have variable height, but there are not so many elements, so i do not need to use a virtual layout
My problem is that this list needs to be updated real-time and i want to make this happen with a nice animation. (e.g. if an item overtakes another by votes, then they swap places.) Anyone knows how to make this animation with Flex 4.5 (spark list)? Do i need to write a custom layout?
View 1 Replies
Oct 14, 2011
The datagrid gets its data from a back end database which has records like
[Code]....
I get errors like 1061: Call to a possibly undefined method refresh through a reference with static type mx.controls:DataGrid. for myRecords.refresh(); and Access of possibly undefined property sort through a reference with static type mx.controls:DataGrid. for myRecords.sort
View 1 Replies
Oct 28, 2011
I have a DatagridColumn in flex with two names, TYPE and NAME. Now, when I am sorting a datagridcolumn, TYPE, it sorts the type using sortcomparefunction and gives the result which contains grouped and sorted order of elements. Ex. if I sort for type I get elements in pdf, doc, ppt in grouped order, but they are internally not sorted, ex: for the pdf part, I have elements such as:
TYPE NAME
pdf A1.pdf
pdf X2.pdf
pdf B1.pdf
Here the filetypes are sorted, but for a particular filetype, the elements are not, please notice that B1 occurs after X2, which should be sorted. Is there a way I can sort the second datagridcolumn after sorting the first one according to filetype extensions? I am using sortcomparefunction for sorting the elements according to type , which works fine. The signature is:
private function sortTheTypeColumn(itemA:Object, itemB:Object):int
View 1 Replies
Jul 30, 2009
I need to to a programmatic multi column sorting on the AdvancedDataGrid.The issue is, currently I am implementing paging on my grid. So, if I sort the data,only the perticular page is being sorted. So,I need to sort the entire list by the column criteria.I tried HeaderRelease event,but I guess it is of no use as I need to make a round trip call to the server to get the sorted data.Is there any way I can implement that.I also need to show the sort markers in the Column headers' right position, indicating the sort numbers and direction.
View 7 Replies
Aug 25, 2009
I extended the DataGridColumn because I wanted to include a custom itemToLabel function (to be able to show nested data in the DataGrid. See this question.
Anyways, it also needs a custom sorting function. So I have written the sorting function like so:
private function mySortCompareFunction(obj1:Object, obj2:Object):int{
var currentData1:Object = obj1;
var currentData2:Object = obj2;
[Code].....
Whenever I try to sort the column, I get the error "Error: Find criteria must contain at least one sort field value."
When I debug and step through each step, I see that the first few times, the function is being called correctly, but towards the end, this error occurs.
View 4 Replies
Oct 11, 2009
I am creating a Datagrid in AS3, and adding a sort function to a column. However, this sort function does never get called. Any ideas?
dg_gruppenUebersicht = new NestedDataGrid;
dg_gruppenUebersicht.sortableColumns = true;
dg_gruppenUebersicht.dataProvider = arrCol_gruppenTnAkt;
[code]....
View 1 Replies
Feb 1, 2010
I'm trying to sort ArrayCollection with following dates, and getting unexpected results.
14-Apr-1980
01-Feb-1975
30-Dec-1977
27-Oct-1968
[Code]...
View 1 Replies
Mar 22, 2010
I have an ArrayCollection where I want to be able to bubble items up or down by one position. What is the best way to do this?
View 2 Replies
May 3, 2010
For example : Having four columns in advance datagrid like company,contact_person,product and date. In this, first i want to sort by product followed by company and followed by date.
View 1 Replies
Aug 18, 2010
I'm creating a table that displays information from a MySQL database, I'm using foreignkeys all over the place to cross-reference data.
Basically I have a datagrid with a column named 'system.' The system is an int that represents the id of an object in another table. I've used lableFunction to cross-reference the two and rename the column. But now sorting doesn't work, I understand that you have to create a custom sorting function. I have tried cross-referencing the two tables again, but that takes ~30sec to sort 1200 rows. Now I'm just clueless as to what I should try next.
Is there any way to access the columns field label inside the sort function?
public function order(a:Object,b:Object):int
{
var v1:String = a.sys;
[Code]....
View 2 Replies
Sep 2, 2010
How to sort date column in datagrid with date format of 'DD/MM/YY'.
View 1 Replies
Aug 26, 2009
I have a flex datagrid. it is bound to an array collection. if the user sorts on column X it works fine. then, if the user causes the array collection to change, the datagrid forgets that it was sorted on column X.what do I need to do to preserve this sort preference so that the new array data will appear sorted by column X?
View 4 Replies
Feb 22, 2010
The sorting capabilities that are available in Flex assume that you have access to all the data, but I'm using a paginated datagrid (with custom code), the datagrid is binded to an ArrayCollection instance, on the next page call I change the data of the dataprovider and everything works ok, but for sorting I need to override the click or event better override the sort method of the arraycollection
All this is to be able to do a server-side sorting.
View 4 Replies
Mar 8, 2011
I have an editable datagrid. If sorting is applied by clicking any header of datagrid, it works fine. But after that, if data values are changed in any row of datagrid, sorting is applied automatically. How to prevent from this behaviour? i.e. sorting should only be applied if user clicks on any header of datagrid and sorting should not be applied when user modifies data in grid.
View 1 Replies