|
Flex Datagrid persistant Caseless Sorting |
|
|
I've been working on a project with multiple data grids with multiple columns. The users requested two things: when they get the refreshed list from the server they would like the datagrid to keep the sort that was on it prior, they also want the sort to be case insensative. Below is the actionscript class I created to do just this. I haven't done much testing, but if I make some major updates I'll update the code! I also plan to have it hold the last selected item and reselect it after the reload of data as well!
I just extended datagrid, and this is Flex 3.0, I am guessing it will work the same with gumbo, and around the same way with advanced data grid.
package classes.extendedComponents { import mx.collections.Sort; import mx.collections.SortField; import mx.controls.Alert; import mx.controls.DataGrid; import mx.controls.dataGridClasses.DataGridColumn; import mx.events.DataGridEvent; import mx.utils.ObjectUtil;
public class InsensativeSortHoldingDataGrid extends DataGrid { public function InsensativeSortHoldingDataGrid() { super(); } override public function set dataProvider(value:Object):void { var temp_sort:Sort = null if ( (dataProvider != null) && (dataProvider.toString() != "") ){ if (dataProvider.sort != null) { temp_sort = dataProvider.sort //Alert.show(sort.toString()) } } for each (var dgc:DataGridColumn in this.columns){ dgc.sortCompareFunction = doCaselessSortForField(dgc.dataField) } super.dataProvider = value if (temp_sort != null){ super.dataProvider.sort = temp_sort super.dataProvider.refresh() } } public function doCaselessSortForField(field:String):Function { return function(obj1:Object, obj2:Object):int { return ObjectUtil.stringCompare(obj1[field],obj2[field],true); } } } |
|
Under Construction
Jibwa.com is under construction. Watch out for broken links, missing pages, potholes and bulldozers. We apologize for the temporary inconvenience - Jibwa.com Staff
News and Updates
Radiology Gallery
Jibwa and Tripwirearts have built and launched a new website with Dr Benjamin Strong. radiologygallery.com for radiology continuing medical educ...
Read More ...
Spark List Vscrollbar on Left side
I spend an unusual amount of time trying to figure out how to set up scrollbars in spark flex (flash builder) beta 2. I wanted a list with the scrollb...
Read More ...
Flex/Flash Builder Params Base
I looked around for a while today at support forums to find out how to include params.base by default in my flash builder flex 4, and flex 3 applicati...
Read More ...
TripwireArts Website
Jibwa LLC partner TripwireArts has a newly designed website with information on some of our clients and established services....
Read More ...
|