Re: [flexcoders] sort compare more than 2 items?
Brendan Meutzner wrote: Why not use numeric values for your priority... you wouldn't have to use a special sort function, but instead just use a labelFunction for display in the datagrid to acheive your high/medium/normal/low counts. Ah nice idea, but I must be thick because I just can't get it to go. I have the array/collection as: public var file_prioritylist:Array = [1, 2, 3, 4 ]; [Bindable] public var file_priority:ArrayCollection = new ArrayCollection(file_prioritylist); I have the labelFunction as: // priority labelFunction public function priorityLabelFunc(item:Object):String { return item.priority + _teststring; } the datagrid is being populated by a remote dataprovider arraycollection which contains the priority etc: Bindable] public var files_datagrid:ArrayCollection; mx:DataGrid id=fileDatagrid x=0 y=0 width=715 height=130 dataProvider={files_datagrid} change=putVideo() selectedIndex=0 and the column in question is laid out as: mx:DataGridColumn id=prioritycolumn headerText=Priority width=90 dataField=priority labelFunction=priorityLabelFunc mx:itemRenderer mx:Component mx:ComboBox dataProvider={parentDocument.file_priority} mx:idfileprioritycb/mx:id /mx:ComboBox /mx:Component /mx:itemRenderer /mx:DataGridColumn Which leads to a error of: Argument count mismatch on Approval_System/priorityLabelFunc(). Expected 1, got 2. if I edit it to move the labelfunction to the combobox and parentDocument it to get to the function I get: Cannot access a property or method of a null object reference. I am sure I am just missing something simple so any insight appreciated Impudent1 LeapFrog Productions
Re: [flexcoders] sort compare more than 2 items?
Hi Tia, I think this accomplishes what you're trying to do... mx:DataGrid id=fileDatagrid x=0 y=0 width=715 height=130 dataProvider={files_datagrid} selectedIndex=0 mx:columns mx:Array mx:DataGridColumn id=prioritycolumn dataField=file_priority headerText=Priority width=90 mx:itemRenderer mx:Component mx:ComboBox selectedIndex={data.file_priority- 1} dataProvider={ parentDocument.file_prioritylist} change=data.file_priority = this.selectedItem.data mx:idfileprioritycb/mx:id /mx:ComboBox /mx:Component /mx:itemRenderer /mx:DataGridColumn /mx:Array /mx:columns /mx:DataGrid mx:Script ![CDATA[ import mx.collections.ArrayCollection; public var file_prioritylist:Array = [{label: 1, data:1}, {label: 2, data:2}, {label: 3, data:3}, {label: 4, data:4}]; [Bindable] public var file_priority:ArrayCollection = new ArrayCollection(file_prioritylist); [Bindable] public var files_datagrid:ArrayCollection = new ArrayCollection; private function init():void { var tmpArray:Array = new Array(); tmpArray.push({file_priority: 1}); tmpArray.push({file_priority: 2}); tmpArray.push({file_priority: 3}); tmpArray.push({file_priority: 4}); files_datagrid.source = tmpArray; } ]] /mx:Script Brendan On 1/27/07, Impudent1 [EMAIL PROTECTED] wrote: Brendan Meutzner wrote: Why not use numeric values for your priority... you wouldn't have to use a special sort function, but instead just use a labelFunction for display in the datagrid to acheive your high/medium/normal/low counts. Ah nice idea, but I must be thick because I just can't get it to go. I have the array/collection as: public var file_prioritylist:Array = [1, 2, 3, 4 ]; [Bindable] public var file_priority:ArrayCollection = new ArrayCollection(file_prioritylist); I have the labelFunction as: // priority labelFunction public function priorityLabelFunc(item:Object):String { return item.priority + _teststring; } the datagrid is being populated by a remote dataprovider arraycollection which contains the priority etc: Bindable] public var files_datagrid:ArrayCollection; mx:DataGrid id=fileDatagrid x=0 y=0 width=715 height=130 dataProvider={files_datagrid} change=putVideo() selectedIndex=0 and the column in question is laid out as: mx:DataGridColumn id=prioritycolumn headerText=Priority width=90 dataField=priority labelFunction=priorityLabelFunc mx:itemRenderer mx:Component mx:ComboBox dataProvider={parentDocument.file_priority} mx:idfileprioritycb/mx:id /mx:ComboBox /mx:Component /mx:itemRenderer /mx:DataGridColumn Which leads to a error of: Argument count mismatch on Approval_System/priorityLabelFunc(). Expected 1, got 2. if I edit it to move the labelfunction to the combobox and parentDocument it to get to the function I get: Cannot access a property or method of a null object reference. I am sure I am just missing something simple so any insight appreciated Impudent1 LeapFrog Productions -- Brendan Meutzner Stretch Media - RIA Adobe Flex Development [EMAIL PROTECTED] http://www.stretchmedia.ca
[flexcoders] sort compare more than 2 items?
I have an array that populates a datagrid combobox item renderer of: public var file_prioritylist:Array = [High, Medium, Normal, Low ]; [Bindable] public var file_priority:ArrayCollection = new ArrayCollection(file_prioritylist); to avoid them sorting alphabetically I setup a sortCompareFunction for that column to use this function: private function prioritySort(item1:Object, item2:Object):int { if (item1.priority == High ) { return 1; } else if( item1.priority == Low ) { return -1; } else { return 0; } } which will get it to sort high or low, but how do I get it to sort the normal and medium appropriately??? I would also like to be able to group the datagrid list by values. http://stackoverflowexception.blogspot.com/2007/01/minor-update-of-grid-component.html has an example of what would pretty well cover it but I cannot get it to work with the swc file. I would also like to be able to learn from the code than just use it. tia Impudent1 LeapFrog Productions
Re: [flexcoders] sort compare more than 2 items?
Why not use numeric values for your priority... you wouldn't have to use a special sort function, but instead just use a labelFunction for display in the datagrid to acheive your high/medium/normal/low counts. Brendan On 1/25/07, Impudent1 [EMAIL PROTECTED] wrote: I have an array that populates a datagrid combobox item renderer of: public var file_prioritylist:Array = [High, Medium, Normal, Low ]; [Bindable] public var file_priority:ArrayCollection = new ArrayCollection(file_prioritylist); to avoid them sorting alphabetically I setup a sortCompareFunction for that column to use this function: private function prioritySort(item1:Object, item2:Object):int { if (item1.priority == High ) { return 1; } else if( item1.priority == Low ) { return -1; } else { return 0; } } which will get it to sort high or low, but how do I get it to sort the normal and medium appropriately??? I would also like to be able to group the datagrid list by values. http://stackoverflowexception.blogspot.com/2007/01/minor-update-of-grid-component.html has an example of what would pretty well cover it but I cannot get it to work with the swc file. I would also like to be able to learn from the code than just use it. tia Impudent1 LeapFrog Productions -- Brendan Meutzner Stretch Media - RIA Adobe Flex Development [EMAIL PROTECTED] http://www.stretchmedia.ca