Sort DataGrid Numerically?
I want to sort numbers numerically (like "1, 3, 10") rather
than alphabetically ("1, 10, 3" ). Everything I've found uses
ActionScript work-arounds on the underlying dataprovider. But
surely I'm missing something and there's an easier way.
Right?
First, make sure your data is in fact numbers and not a
string with numerials in it. This is one of those things I can't
seem to keep in my head, so you'll need to experiment first. If
that doesn't work (I think it will), then you need to create a Sort
and a SortItem. The Sort is added to the dataProvider collection,
not to the DataGrid.
Similar Messages
-
How to sort alphanumeric values in datagrid numerically
Hi all,
I have a datagrid column which contains AlphaNumeric values.Is there a way i can sort these values in a numerical order
eg:
having d1,d11,12,13,d2,d3,d4
d2 should come after d1..
order should be d1,d2,d3,d4,d11,d12,d13
Please help me out..if any have any idea..giving below thw code which is sorting as string
protected function ColumnSortCompare( obj1:Object, obj2:Object ):int
if ( !obj1 && !obj2 )
return 0;
if ( !obj1 )
return 1;
if ( !obj2 )
return -1;
var obj1Data:String = ComplexColumnData( obj1 ).toString();
var obj2Data:String = ComplexColumnData( obj2 ).toString();
if ( obj1Data < obj2Data )
return -1;
if ( obj1Data > obj2Data )
return 1;
return 0;
Thanx in advance
RajeshHi,
Thanks for the reply. Please dont mind if the question is simple,as I am new to flex.
While I am using
return ObjectUtil.stringCompare(obj1[fieldName], obj2[fieldName]);
it is throwing error as, undefined property fieldName.
I am calling as this
<mx:DataGridColumn headerText=""
editable="false"
sortCompareFunction="ColumnSortCompare"
textAlign="left"
dataField="{PORT_NAME}"
width="150"/>
How I can resolve this.Please guide me.
Thanks,
Raj -
Sorting non numeric column based on numeric column value
APEX 3.1 - RDBMS 10Gr2
In this example, I have a report with 2 columns: (1) numeric IP address (no periods embedded) and (2) varchar IP address (IP address with periods). I would like to display the varchar IP column on the report but sort by the numeric IP address values when the user attempts to sort on the displayed (varchar IP) column in the report.
I would like to do this in Interactive Reports (if possible) but am willing to do this using the conventional report (non IR).
Any thoughts are appreciated. Thanks in advance.
Barry D.Barry:
You and do this in a classic report as follows
1) Report query -> Select f1_num, f2_char from table
2) Report Attributes -> Edit Column f1_num - > HTML Expression -> Set to #f2_char# -> Apply Changes
3) Report Attributes -> Uncheck 'Show' for f2_char
Varad -
Bug in sort of numeric values in ( title and album ) string.
The Bug in the sort-function of the iPod results in mixed up track list.
An album with more then 9 tracks will be sorted in the wrong way, when only title or filename or album field is just to give a track a number. The play order is 1, 10, 11, 12, 13, 2, 3 , 4 , 5, 6.... instead of the correct order 1,2,3,4,5,6...10,11, 12...
For example: After playing the track named "The Beatles - Yellow Submarine - 1 - Yellow Submarine" the ipod will play "The Beatles - Yellow Submarine - 10 - Baby, You´re A Rich Man" instead of "The Beatles - Yellow Submarine - 2 - Hey Bulldog."
The programmer have to search the string for numbers and join all numeric values to a single number.
Example: Sample data :abc123. is "a" a number? no. is "b" a number no. is "c" a number no. is "1" a number? yes. store. is "2" a number? yes. join to "1". (now we have "12"). is "3" a number? yes. join to "12". (Now we have "123") -> EOL
Is "123" largen than "99"? yes! is "123" larger than 124. no!
Thats it. In perl you need 1 line of sourcecode, in c and c++ this can be done in 10 lines. In java (there a objects for this type of sort).
And every user will be happy and nobody has to do the 01, 02, 03 workaround or reimport their audiobooks.
Alternativly Apple should thing about storing the original filename in the ID3 tag or itunes database. This would make sorting the files without id3 tags (believe me or not, there are many people using mp3 for 10 years and have no id3 tags in there mp3-library) in itunes possible. (there is a god free tagger for mac os but no for windows.)
A company like Apple should have the ability to correct the error / bug in the iPod-firmware (have the same issue in classic and iphone) or itunes-softwar.
This is a wellknown and very common error done by newbie programmers or people who have not read the documentation of the software-libraries.I still have an H140 in the cupboard. As I recall that needs leading zeros on filenames to sort properly. Since both WMP & iTunes include leading zeros it was never really an issue. THE Rename should be able to extract the track numbers from part of the filename and is also able to generate counters, along with the usual functions of setting tag fields from part of the file and/or folder name. Unfortuanetly THE Rename is still on the complicated side - I suspect there would be no easy way to lump together the variety of options that it has while keeping it very simple.
Once you've used an external program to adjust the tags you can make iTunes re-read them just by selecting the group of files in question, using CRTL-I to "Get Info." and then clicking OK +without making any changes+. iTunes will recheck it's database against any values in the tag and update as required. Given the lack of existing tags I would imagine that you don't let iTunes reorganise your music at the moment and would suggest you keep things that way at least until you are sure that all the tags have been correctly applied and you have a suitable backup. I stick to a Artist/Album/## Track structure which I don't let iTunes manage so that I can always recover details from the filesnames if I should ever accidentally edit more tracks than I intend.
tt2 -
How not to sort datagrid column on double click
Hello,
I am currently building an application containing a datagrid for data representation. I've created a custom datagridheader in order to add a input text for filtering the columns (see code below).
My goal is to hide the textinput, and then show it on a double click on the header. So i would like to know how to avoid the sort of this column each time i double click.?
<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" resize="onColumnResize(event)" clipAndEnableScrolling="true" doubleClick="managefilterField(event)">
<fx:Declarations>
<!--- The default value of the <code>sortIndicator</code> property.
It must be an IFactory for an IVisualElement.
<p>This value is specified in a <code>fx:Declaration</code> block and can be overridden
by a declaration with <code>id="defaultSortIndicator"</code>
in an MXML subclass.</p>
@langversion 3.0
@playerversion Flash 10
@playerversion AIR 2.0
@productversion Flex 4.5
-->
<fx:Component id="defaultSortIndicator">
<s:Path data="M 3.5 7.0 L 0.0 0.0 L 7.0 0.0 L 3.5 7.0" implements="spark.components.gridClasses.IGridVisualElement">
<fx:Script>
<![CDATA[
import spark.components.DataGrid;
import spark.components.Grid;
* @private
public function prepareGridVisualElement(grid:Grid, rowIndex:int, columnIndex:int):void
const dataGrid:DataGrid = grid.dataGrid;
if (!dataGrid)
return;
const color:uint = dataGrid.getStyle("symbolColor");
arrowFill1.color = color;
arrowFill2.color = color;
]]>
</fx:Script>
<s:fill>
<s:RadialGradient rotation="90" focalPointRatio="1">
<!--- @private -->
<s:GradientEntry id="arrowFill1" color="0" alpha="0.6" />
<!--- @private -->
<s:GradientEntry id="arrowFill2" color="0" alpha="0.8" />
</s:RadialGradient>
</s:fill>
</s:Path>
</fx:Component>
<!--- Displays the renderer's label property, which is set to the column's <code>headerText</code>.
It must be an instance of a <code>TextBase</code>, like <code>s:Label</code>.
<p>This visual element is added to the <code>labelDisplayGroup</code> by the renderer's
<code>prepare()</code> method. Any size/location constraints specified by the labelDisplay
define its location relative to the labelDisplayGroup.</p>
<p>This value is specified with a <code>fx:Declaration</code> and can be overridden
by a declaration with <code>id="labelDisplay"</code>
in an MXML subclass.</p>
@langversion 3.0
@playerversion Flash 10
@playerversion AIR 2.0
@productversion Flex 4.5
-->
<s:Label id="labelDisplay"
verticalCenter="1" left="0" right="0" top="0" bottom="0"
textAlign="start"
fontWeight="bold"
verticalAlign="middle"
maxDisplayedLines="1"
showTruncationTip="true" />
</fx:Declarations>
<fx:Script>
<![CDATA[
import net.awl.ismp.console.components.misc.FilterCriteria;
import net.awl.ismp.console.events.ColumnFilteredEvent;
import net.awl.ismp.console.events.ColumnResizedEvent;
import mx.events.ResizeEvent;
import spark.components.gridClasses.IGridVisualElement;
import mx.core.IVisualElement;
import spark.components.DataGrid;
import spark.components.GridColumnHeaderGroup;
import spark.components.gridClasses.GridColumn;
import spark.primitives.supportClasses.GraphicElement;
// chrome color constants and variables
private static const DEFAULT_COLOR_VALUE:uint = 0xCC;
private static const DEFAULT_COLOR:uint = 0xCCCCCC;
private static const DEFAULT_SYMBOL_COLOR:uint = 0x000000;
private static var colorTransform:ColorTransform = new ColorTransform();
* @private
private function dispatchChangeEvent(type:String):void
if (hasEventListener(type))
dispatchEvent(new Event(type));
protected function onColumnResize(event:ResizeEvent):void
dispatchEvent(new ColumnResizedEvent(ColumnResizedEvent.COLUMNRESIZED_EVT,this.width,this.column.columnInde x));
// maxDisplayedLines
private var _maxDisplayedLines:int = 1;
[Bindable("maxDisplayedLinesChanged")]
[Inspectable(minValue="-1")]
* The value of this property is used to initialize the
* <code>maxDisplayedLines</code> property of this renderer's
* <code>labelDisplay</code> element.
* @copy spark.components.supportClasses.TextBase#maxDisplayedLines
* @default 1
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion Flex 4.5
public function get maxDisplayedLines():int
return _maxDisplayedLines;
override protected function stateChanged(oldState:String, newState:String, recursive:Boolean):void
trace("state changed from : "+oldState+" to "+newState);
super.stateChanged(oldState, newState, recursive);
* @private
public function set maxDisplayedLines(value:int):void
if (value == _maxDisplayedLines)
return;
_maxDisplayedLines = value;
if (labelDisplay)
labelDisplay.maxDisplayedLines = value;
invalidateSize();
invalidateDisplayList();
dispatchChangeEvent("maxDisplayedLinesChanged");
// sortIndicator
private var _sortIndicator:IFactory;
private var sortIndicatorInstance:IVisualElement;
[Bindable("sortIndicatorChanged")]
* A visual element that's displayed when the column is sorted.
* <p>The sortIndicator visual element is added to the <code>sortIndicatorGroup</code>
* by this renderer's <code>prepare()</code> method. Any size/location constraints
* specified by the sortIndicator define its location relative to the sortIndicatorGroup.</p>
* @default null
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion Flex 4.5
public function get sortIndicator():IFactory
return (_sortIndicator) ? _sortIndicator : defaultSortIndicator;
* @private
public function set sortIndicator(value:IFactory):void
trace("setSortIndicator");
if (_sortIndicator == value)
return;
_sortIndicator = value;
if (sortIndicatorInstance)
sortIndicatorGroup.includeInLayout = false;
sortIndicatorGroup.removeElement(sortIndicatorInstance);
sortIndicatorInstance = null;
invalidateDisplayList();
dispatchChangeEvent("sortIndicatorChanged");
* @private
* Create and add the sortIndicator to the sortIndicatorGroup and the
* labelDisplay into the labelDisplayGroup.
override public function prepare(hasBeenRecycled:Boolean):void
trace("prepare !!");
super.prepare(hasBeenRecycled);
if (labelDisplay && labelDisplayGroup && (labelDisplay.parent != labelDisplayGroup))
labelDisplayGroup.removeAllElements();
labelDisplayGroup.addElement(labelDisplay);
trace(sortIndicator);
trace("sortIndicatorInstance : "+sortIndicatorInstance);
const column:GridColumn = this.column;
if (sortIndicator && column && column.grid && column.grid.dataGrid && column.grid.dataGrid.columnHeaderGroup)
const dataGrid:DataGrid = column.grid.dataGrid;
const columnHeaderGroup:GridColumnHeaderGroup = dataGrid.columnHeaderGroup;
if (columnHeaderGroup.isSortIndicatorVisible(column.columnIndex))
if (!sortIndicatorInstance)
sortIndicatorInstance = sortIndicator.newInstance();
sortIndicatorGroup.addElement(sortIndicatorInstance);
chromeColorChanged = true;
invalidateDisplayList();
// Initialize sortIndicator
sortIndicatorInstance.visible = true;
const gridVisualElement:IGridVisualElement = sortIndicatorInstance as IGridVisualElement;
if (gridVisualElement)
gridVisualElement.prepareGridVisualElement(column.grid, -1, column.columnIndex);
sortIndicatorGroup.includeInLayout = true;
sortIndicatorGroup.scaleY = (column.sortDescending) ? 1 : -1;
else
if (sortIndicatorInstance)
sortIndicatorGroup.removeElement(sortIndicatorInstance);
sortIndicatorGroup.includeInLayout = false;
sortIndicatorInstance = null;
private var chromeColorChanged:Boolean = false;
private var colorized:Boolean = false;
* @private
* Apply chromeColor style.
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
//trace("update display list");
// Apply chrome color
if (chromeColorChanged)
var chromeColor:uint = getStyle("chromeColor");
if (chromeColor != DEFAULT_COLOR || colorized)
colorTransform.redOffset = ((chromeColor & (0xFF << 16)) >> 16) - DEFAULT_COLOR_VALUE;
colorTransform.greenOffset = ((chromeColor & (0xFF << 8)) >> 8) - DEFAULT_COLOR_VALUE;
colorTransform.blueOffset = (chromeColor & 0xFF) - DEFAULT_COLOR_VALUE;
colorTransform.alphaMultiplier = alpha;
transform.colorTransform = colorTransform;
var exclusions:Array = [labelDisplay, sortIndicatorInstance];
// Apply inverse colorizing to exclusions
if (exclusions && exclusions.length > 0)
colorTransform.redOffset = -colorTransform.redOffset;
colorTransform.greenOffset = -colorTransform.greenOffset;
colorTransform.blueOffset = -colorTransform.blueOffset;
for (var i:int = 0; i < exclusions.length; i++)
var exclusionObject:Object = exclusions[i];
if (exclusionObject &&
(exclusionObject is DisplayObject ||
exclusionObject is GraphicElement))
colorTransform.alphaMultiplier = exclusionObject.alpha;
exclusionObject.transform.colorTransform = colorTransform;
colorized = true;
chromeColorChanged = false;
super.updateDisplayList(unscaledWidth, unscaledHeight);
* @private
override public function styleChanged(styleProp:String):void
var allStyles:Boolean = !styleProp || styleProp == "styleName";
super.styleChanged(styleProp);
if (allStyles || styleProp == "chromeColor")
chromeColorChanged = true;
invalidateDisplayList();
protected function managefilterField(event:MouseEvent):void
trace("double click sortIndicator : "+this.sortIndicatorInstance);
this.filterInput.visible=!this.filterInput.visible;
this.filterInput.includeInLayout=this.filterInput.visible;
this.filterSpacer.visible=this.filterInput.visible;
this.filterSpacer.includeInLayout=this.filterInput.visible;
if(!this.filterInput.visible)
this.filterInput.text="";
dispatchEvent(new ColumnFilteredEvent(ColumnFilteredEvent.COLUMNFILTERED_EVT,new FilterCriteria(this.column.dataField,this.filterInput.text)));
this.filterInput.setStyle("borderColor",0xFF6319);
this.filterInput.setStyle("focusColor",0xFF6319);
//this.filterInput.setStyle(
protected function onTextInputSelection(event:MouseEvent):void
event.stopImmediatePropagation();
this.filterInput.setStyle("borderColor",0xFF6319);
this.filterInput.setStyle("focusColor",0xFF6319);
protected function onKeyUp(event:KeyboardEvent):void
if(event.charCode==Keyboard.ENTER)
stage.focus=null;
protected function onFocusOut(event:FocusEvent):void
this.filterInput.setStyle("borderColor",0x00ff00);
this.filterInput.setStyle("focusColor",0x70B2EE);
dispatchEvent(new ColumnFilteredEvent(ColumnFilteredEvent.COLUMNFILTERED_EVT,new FilterCriteria(this.column.dataField,this.filterInput.text)));
]]>
</fx:Script>
<s:states>
<s:State name="normal" />
<s:State name="hovered" />
<s:State name="down" />
</s:states>
<!-- layer 1: shadow -->
<!--- @private -->
<s:Rect id="shadow" left="-1" right="-1" top="-1" bottom="-1" radiusX="2">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0x000000"
color.down="0xFFFFFF"
alpha="0.01"
alpha.down="0" />
<s:GradientEntry color="0x000000"
color.down="0xFFFFFF"
alpha="0.07"
alpha.down="0.5" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<!-- layer 2: fill -->
<!--- @private -->
<s:Rect id="fill" left="0" right="0" top="0" bottom="0">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xFFFFFF"
color.hovered="0xBBBDBD"
color.down="0xAAAAAA"
alpha="0.85" />
<s:GradientEntry color="0xD8D8D8"
color.hovered="0x9FA0A1"
color.down="0x929496"
alpha="0.85" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<!-- layer 3: fill lowlight -->
<!--- @private -->
<s:Rect id="lowlight" left="0" right="0" top="0" bottom="0">
<s:fill>
<s:LinearGradient rotation="270">
<s:GradientEntry color="0x000000" ratio="0.0" alpha="0.0627" />
<s:GradientEntry color="0x000000" ratio="0.48" alpha="0.0099" />
<s:GradientEntry color="0x000000" ratio="0.48001" alpha="0" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<!-- layer 4: fill highlight -->
<!--- @private -->
<s:Rect id="highlight" left="0" right="0" top="0" bottom="0">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xFFFFFF"
ratio="0.0"
alpha="0.33"
alpha.hovered="0.22"
alpha.down="0.12"/>
<s:GradientEntry color="0xFFFFFF"
ratio="0.48"
alpha="0.33"
alpha.hovered="0.22"
alpha.down="0.12" />
<s:GradientEntry color="0xFFFFFF"
ratio="0.48001"
alpha="0" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<!-- layer 5: highlight stroke (all states except down) -->
<!--- @private -->
<s:Rect id="highlightStroke" left="0" right="0" top="0" bottom="0" excludeFrom="down">
<s:stroke>
<s:LinearGradientStroke rotation="90" weight="1">
<s:GradientEntry color="0xFFFFFF" alpha.hovered="0.22" />
<s:GradientEntry color="0xD8D8D8" alpha.hovered="0.22" />
</s:LinearGradientStroke>
</s:stroke>
</s:Rect>
<!-- layer 6: highlight stroke (down state only) -->
<!--- @private -->
<s:Rect id="hldownstroke1" left="0" right="0" top="0" bottom="0" includeIn="down">
<s:stroke>
<s:LinearGradientStroke rotation="90" weight="1">
<s:GradientEntry color="0x000000" alpha="0.25" ratio="0.0" />
<s:GradientEntry color="0x000000" alpha="0.25" ratio="0.001" />
<s:GradientEntry color="0x000000" alpha="0.07" ratio="0.0011" />
<s:GradientEntry color="0x000000" alpha="0.07" ratio="0.965" />
<s:GradientEntry color="0x000000" alpha="0.00" ratio="0.9651" />
</s:LinearGradientStroke>
</s:stroke>
</s:Rect>
<!--- @private -->
<s:Rect id="hldownstroke2" left="1" right="1" top="1" bottom="1" includeIn="down">
<s:stroke>
<s:LinearGradientStroke rotation="90" weight="1">
<s:GradientEntry color="0x000000" alpha="0.09" ratio="0.0" />
<s:GradientEntry color="0x000000" alpha="0.00" ratio="0.0001" />
</s:LinearGradientStroke>
</s:stroke>
</s:Rect>
<!--<s:Rect id="fill" left="0" right="0" top="0" bottom="0">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color.normal="0xf9f9f9" color.hovered="0xfcfdfa"
color.down="0xdceac2" alpha="0.85" />
<s:GradientEntry color.normal="0xeaeaea" color.hovered="0xdceac2"
color.down="0xd2e1b5" alpha="0.85" />
</s:LinearGradient>
</s:fill>
</s:Rect>-->
<!--<s:VGroup left="7" right="7" top="5" bottom="5" gap="6" verticalAlign="middle">
<s:TextInput width="100%" />
<s:HGroup width="100%">
<s:Group id="labelDisplayGroup" width="100%" />
<s:Group id="sortIndicatorGroup" includeInLayout="false" />
</s:HGroup>
</s:VGroup>-->
<s:VGroup verticalAlign="middle" left="7" top="5" right="7" bottom="5" gap="2" >
<s:TextInput id="filterInput" width="100%" visible="false" includeInLayout="false" keyUp="onKeyUp(event)" focusOut="onFocusOut(event)" click="onTextInputSelection(event)"/>
<s:Spacer id="filterSpacer" visible="false" includeInLayout="false" height="5" />
<s:HGroup width="100%" height="100%" verticalAlign="middle">
<s:Group id="labelDisplayGroup" width="100%" />
<s:Group id="sortIndicatorGroup" includeInLayout="false" />
</s:HGroup>
</s:VGroup>
</s:GridItemRenderer>Based on your idea, i've intercepted the click event and I use stopImmediatePropagation.
THen i added an image to sort the column. So if the image is clicked the sort is ok. -
Strange application behaviour after try to sort datagrid column
Hi all
I have a simple Air desktop application with customized DataGrid (Spark version). Problem that users found is when they trying to sort grid by one of the columns applicaiton closes without any messages. I've repeated this bug on my PC but there is a problem - in debug mode (i mean with ADL) it works OK without any tries to crash on sort. So my questions in priority order:
1. Is that possible to obtain live Air application errors log? I mean after installation. Maybe with 3rd party applicaiton. I'm using MonsterDebugger and added few log messages but looks like application just crashes without firing closing or close event.
2. Which part of DataGrid could crash applicaiton in release mode? Just thought debug mode is more strict.
My dev system:
Flash Builder 4.6
Adobe Air 3.2
Win 7 Ultimate 64bit
Best regards, Roman
P.S. Sorry for my bad englishBased on your idea, i've intercepted the click event and I use stopImmediatePropagation.
THen i added an image to sort the column. So if the image is clicked the sort is ok. -
I would like to be able to sort the entries in "Notes" alpha numerically. By default these entries are sorted based on the date of creation of the entry.
As I said, it works perfectly well for me. Try putting the sidebar into Contact Sheet mode and see if the dates are sorted correctly. Here's an example from my machine:
As you can see, if you have good eyes, all are arranged in date order, regardless of day, month or year.
Just two things occur to me about your problem. I see that your date format differs significantly from mine. Try changing it in System Preferences->Language & Text->Formats and see if that has an effect. There may be a bug in regard to how Preview handles the various date formats. You might also try logging into your test account and see if Preview behaves correctly there, with everything in the default state. If you don't have a test account, create one. Leave everything in the default state and keep it around for future tests--it doesn't take much space and is very handy to have around.
Francine
Francine
Schwieder -
Sort datagrid column in groupby
Hai
can any one help to sort the advanced datagrid column in ascending
by default the values will be in groupby format..
how to sort in groupby...
Thanks in AdvanceHai
can any one help to sort the advanced datagrid column in ascending
by default the values will be in groupby format..
how to sort in groupby...
Thanks in Advance -
Sort DataGrid with dataprovider XMLisCollection
I can't get my datagrid to sort when I have a
XMLListcollection as the dataprovider and I have to use a
labelfunction to get the records to display because of the
namespace in the XML (Replicating a .NET web service).
Can someone help, Please?
I have the following code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="vertical" creationComplete="initApp()" >
<mx:Script>
<![CDATA[
import mx.controls.dataGridClasses.DataGridColumn;
import mx.controls.DataGrid;
import mx.events.DataGridEvent;
import mx.collections.*;
import mx.controls.Alert;
import mx.formatters.DateFormatter;
//the dataProvider for the DG
[Bindable]
private var _xlc:XMLListCollection;
[Bindable]
private var sortA:Sort;
// The sort fields used to determine the sort.
private var sortBySeverity:SortField;
private var sortByRequestor:SortField;
public function initApp():void
namespace myNameS = "myNamespace.Test";
use namespace myNameS;
_xlc = new
XMLListCollection(GetRequestList.*..SafRequestListVO);
//testing element values
trace(GetRequestList.*..SafRequestListVO.SeverityLevel);
sortA = new Sort();
sortBySeverity = new SortField("SeverityLevel", true, true);
sortByRequestor = new SortField("Requestor", true);
sortA.fields=[sortBySeverity, sortByRequestor];
_xlc.sort=sortA;
_xlc.refresh();
dg.dataProvider = _xlc;
dg.rowCount=_xlc.length +1;
/**labelFunction to return data to DG by reference of
dataField*/
private function LF(item:Object,
column:DataGridColumn):Object
namespace myNameS = "myNamespace.Test";
use namespace myNameS;
var colDataField:Object = column.dataField;
switch (colDataField) //logic to determine which node to get
the data from
case "SAFNumber":
return item.SAFNumber;
break;
case "RequestDate":
var date:String = new String(item.RequestDate).toString();
var df:DateFormatter = new DateFormatter();
df.formatString = "YYYY-MM-DD";
return df.format(date);
break;
case "SeverityLevel":
return item.SeverityLevel;
break;
case "Requestor":
return item.Requestor;
break;
case "IssuedToDepartment":
return item.IssuedToDepartment;
break;
default:
return item.dataField;
break;
]]></mx:Script>
<mx:Canvas id="datagridParent" borderStyle="solid"
height="450" width="100%" >
<mx:DataGrid id="dg" width="100%" height="100%"
rowCount="5" labelFunction="LF">
<mx:columns>
<mx:DataGridColumn dataField="SAFNumber"
headerText="SAFNumber"/>
<mx:DataGridColumn dataField="Requestor"
headerText="Requestor"/>
<mx:DataGridColumn dataField="RequestDate"
headerText="RequestDate"/>
<mx:DataGridColumn dataField="IssuedToDepartment"
headerText="IssuedToDepartment"/>
<mx:DataGridColumn dataField="SeverityLevel"
headerText="SeverityLevel"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
<mx:XML id="GetRequestList" format="e4x">
<GetRequestListResponse xmlns="myNamespace.Test">
<GetRequestListResult>
<SafRequestListVO>
<RequestGuid>3F2504E0-4F89-11D3-9A0C-0305E82C3301</RequestGuid>
<SAFNumber>1</SAFNumber>
<RequestDate>03/24/2007</RequestDate>
<Requestor>Michael</Requestor>
<IssuedToDepartment>1</IssuedToDepartment>
<IssuedToArea>3</IssuedToArea>
<IssuedByDepartment>string</IssuedByDepartment>
<Problem>Problem Details........Problem
Details........</Problem>
<SeverityLevel>3</SeverityLevel>
<CurrentState>string</CurrentState>
</SafRequestListVO>
<SafRequestListVO>
<RequestGuid>3F2504E0-4F89-11D3-9A0C-0305E82C3302</RequestGuid>
<SAFNumber>2</SAFNumber>
<RequestDate>02/21/2006</RequestDate>
<Requestor>Bill</Requestor>
<IssuedToDepartment>1</IssuedToDepartment>
<IssuedToArea>2</IssuedToArea>
<IssuedByDepartment>string</IssuedByDepartment>
<Problem>Problem Details........Problem
Details........Problem Details........Problem
Details........Problem Details........</Problem>
<SeverityLevel>1</SeverityLevel>
<CurrentState>string</CurrentState>
</SafRequestListVO>
<SafRequestListVO>
<RequestGuid>3F2504E0-4F89-11D3-9A0C-0305E82C3303</RequestGuid>
<SAFNumber>3</SAFNumber>
<RequestDate>01/06/2007</RequestDate>
<Requestor>Jonathan</Requestor>
<IssuedToDepartment>8</IssuedToDepartment>
<IssuedToArea>2</IssuedToArea>
<IssuedByDepartment>string</IssuedByDepartment>
<Problem>string</Problem>
<SeverityLevel>1</SeverityLevel>
<CurrentState>string</CurrentState>
</SafRequestListVO>
<SafRequestListVO>
<RequestGuid>3F2504E0-4F89-11D3-9A0C-0305E82C3304</RequestGuid>
<SAFNumber>4</SAFNumber>
<RequestDate>03/27/2007</RequestDate>
<Requestor>Bill</Requestor>
<IssuedToDepartment>7</IssuedToDepartment>
<IssuedToArea>2</IssuedToArea>
<IssuedByDepartment>string</IssuedByDepartment>
<Problem>Problem Details........Problem
Details........Problem Details........Problem
Details........Problem Details........</Problem>
<SeverityLevel>3</SeverityLevel>
<CurrentState>string</CurrentState>
</SafRequestListVO>
<SafRequestListVO>
<RequestGuid>3F2504E0-4F89-11D3-9A0C-0305E82C3305</RequestGuid>
<SAFNumber>5</SAFNumber>
<RequestDate>12/21/2006</RequestDate>
<Requestor>Mike</Requestor>
<IssuedToDepartment>4</IssuedToDepartment>
<IssuedToArea>2</IssuedToArea>
<IssuedByDepartment>string</IssuedByDepartment>
<Problem>string</Problem>
<SeverityLevel>2</SeverityLevel>
<CurrentState>string</CurrentState>
</SafRequestListVO>
<SafRequestListVO>
<RequestGuid>3F2504E0-4F89-11D3-9A0C-0305E82C3306</RequestGuid>
<SAFNumber>6</SAFNumber>
<RequestDate>04/02/2007</RequestDate>
<Requestor>Nick</Requestor>
<IssuedToDepartment>2</IssuedToDepartment>
<IssuedToArea>2</IssuedToArea>
<IssuedByDepartment>string</IssuedByDepartment>
<Problem>Problem Details........Problem
Details........Problem Details........Problem
Details........Problem Details........</Problem>
<SeverityLevel>3</SeverityLevel>
<CurrentState>string</CurrentState>
</SafRequestListVO>
<SafRequestListVO>
<RequestGuid>3F2504E0-4F89-11D3-9A0C-0305E82C3307</RequestGuid>
<SAFNumber>7</SAFNumber>
<RequestDate>03/27/2007</RequestDate>
<Requestor>Sandeep</Requestor>
<IssuedToDepartment>4</IssuedToDepartment>
<IssuedToArea>2</IssuedToArea>
<IssuedByDepartment>string</IssuedByDepartment>
<Problem>Problem Details........Problem
Details........Problem Details........Problem
Details........</Problem>
<SeverityLevel>2</SeverityLevel>
<CurrentState>string</CurrentState>
</SafRequestListVO>
</GetRequestListResult>
</GetRequestListResponse>
</mx:XML>
</mx:Application>Michael, I am sorry, but I myself have significant difficulty
with xml namespaces. I have managed to get some examples working
but only by trial and error and studying up on Namespace in the
docs.
http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&objectID=582
I am just not good enough with them to be able to tell you
what you need to do.
Tracy -
can someone show me how to sort this in numerical order?
only the first column in order, but the rest of the columns will follow the sorted values.
does that make sense?
Solved!
Go to Solution.Cool set of VIs, thanks for sharing pcardinale.
In this special case the following simple code would also work.
Ben64
Attachments:
Untitled 2.vi 11 KB -
I have a DataGrid with several columns and I would like to be
able to sort it with a ComboBox. So if option a in the comboBox is
selected then column A in the DataGrid will be used to sort. I
option B is selected then a different column wil sort the DataGrid.
How would I go about this?
Thanks
Dave"dmschenk" <[email protected]> wrote in
message
news:gbe16o$c4p$[email protected]..
> I have a DataGrid with several columns and I would like
to be able to sort
> it
> with a ComboBox. So if option a in the comboBox is
selected then column A
> in
> the DataGrid will be used to sort. I option B is
selected then a
> different
> column wil sort the DataGrid. How would I go about this?
I think there's an example of this at
http://blog.flexexamples.com -
argh, frustrating!
Is it really possible that I cant sort a datagrid with script
when user presses the button.
Lets say datagrid have three columns. Col 1, col 2 and col 3.
I have three buttons that lead user to the datagrid and each
of them should sort the datagrid by the column user clicked
(equivalent button)?Just sort the underlying collection. Assuming your using an
arrayCollection
do the following:
userList.source.sortOn(["org","name"]);
This is a collection of user objects where I sort by org and
name.
Then either reset the grids dataprovider or send out a
Collection changed event:
var c:CollectionEvent = new
CollectionEvent(CollectionEvent.COLLECTION_CHANGE);
userList.dispatchEvent(c) -
One datagrid, numerous (xml) datasources
i have a prospective application with the following setup:
one datagrid, with numerous buttons elsewhere in the
application
desired procedure:
upon clicking one of the buttons -
the datagrid is unloaded of any datasource previously loaded
(is this necessary?);
the datagrid is populated with a specific, different xml
datasource (xml file) assigned to a specific button(while showing
busyCursor, and upon completion of data load, normal cursor is
returned).
any help would be appreciated.This article sounds like what you are doing:
http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=4041&produ ctId=2&loc=en_US -
they show up that way on iTunes when connected to the Nano, (in numerical order) but on the Nano, they're out of order. The shake to shuttle is off.
I dragged and dropped it from my desktop to my Nano (through iTunes) and it all loaded in order...if I take it from iTunes, it syncs everything, not just one playlist....even though I choose only one playlist...
??? So you are manually managing your iPod's contents. i.e you drag and drop content onto your Nano from under the Devices section in the left hand pane of iTunes.
What did you drag and drop?
B-rock -
How to sorting character + numeric in oracle?
Please help to sort below String in Oracle.
BR 77002000 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:1234
MR 13000 in Finance No. 48-2010, P-ZIP: 75019, SAccountNumber:N/A
MR 77050001 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A
MR 1302 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A
PI 130 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A
PI 6780 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A
Thanks.
John2 examples
with strs as (
select 'BR 77002000 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:1234' str from dual union all
select 'MR 13000 in Finance No. 48-2010, P-ZIP: 75019, SAccountNumber:N/A' from dual union all
select 'MR 77050001 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A' from dual union all
select 'MR 1302 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A' from dual union all
select 'PI 130 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A' from dual union all
select 'PI 6780 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A' from dual)
select str from strs
order by nlssort(str,'NLS_SORT=FRENCH')
select str from strs
order by substr(str,instr(str,':',-1),length(str)-instr(str,':',-1)) desc
some more
SELECT str,REGEXP_substr ( str, '[[:digit:]]+',1)
FROM strs
ORDER BY REGEXP_substr ( str, '[[:digit:]]+',1)
STR REGEXP_SUBSTR(STR,'[[:DIGIT:]]+',1)
PI 130 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A 130
MR 13000 in Finance No. 48-2010, P-ZIP: 75019, SAccountNumber:N/A 13000
MR 1302 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A 1302
PI 6780 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A 6780
BR 77002000 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:1234 77002000
MR 77050001 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A 77050001
SELECT str,REGEXP_substr ( str, '[[:digit:]-]+',1,2)
FROM strs
ORDER BY REGEXP_substr ( str, '[[:digit:]-]+',1,2)
STR REGEXP_SUBSTR(STR,'[[:DIGIT:]-]+',1,2)
MR 13000 in Finance No. 48-2010, P-ZIP: 75019, SAccountNumber:N/A 48-2010
PI 6780 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A 66-1204
MR 1302 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A 66-1204
PI 130 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A 66-1204
BR 77002000 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:1234 66-1204
MR 77050001 in Finance No. 66-1204, P-ZIP: 20260, SAccountNumber:N/A 66-1204Edited by: chris227 on 06.02.2012 11:18
Edited by: chris227 on 06.02.2012 11:23
Edited by: chris227 on 06.02.2012 11:23
Maybe you are looking for
-
Cannot Import javax.swing.JOptionPane Please HELP!!!
import javax.swing.JOptionPane; this line of code returns the error: C:\Java Files\BankAccount\BankAccount_Test.java:1: Class javax.swing.JOptionPane not found in import. import javax.swing.JOptionPane; ^ 1 error Process completed. Please help, I don
-
Save me! Missing pics after import from CD? what the..?
Hello Mac superstars, I'm on a macbook pro from late 2011, on lion so I think that I would then have iphoto 11? Here's my story: - Imported some photos from disc & first event created. But after ejecting disc, couldn't view pictures in iphoto (thumb
-
Generating WSDL using Integration Directory (Tools-Define Web Service)
Hi, I have tested the "Define Web Service" tool in Integration Directory - some question; 1) It's a little bit frustrating to change the URL after clicking the "Propose URL" button - is it possible to configure somewhere the right URL http://<srv>:<p
-
I have an iPod which I currently sync on my iMac, but I want to sync it on my Apple mac pro, how do I do this? Is there a way of doing it without restoring my iPod?
-
When I install Flash Professional CC, it repeatedly ends in a message stating that the download is corrupt, with code 42. When I launch the application, everything works fine until I want to export my file as a GIF animation. This results in a crash