Reputation: 72
I want to fix first row data in datagrid according to a coloumn Status, if data status is new then it should be on index 0 first row, and sort other datagrid rows based on the date coloumn. i already sorted all data on the base of a single coloum like date. i also tried to sort with the given function but it's not working fine.
public static function sortDataGridMultiColumn(columnOne: String, columnTwo: String, decending: Boolean, array: ArrayCollection): void {
var sortThese: Sort = new Sort();
sortThese.fields = [new SortField(columnOne, false, decending),
new SortField(columnTwo, false, decending)];
array.sort = sortThese;
array.refresh();
}
Upvotes: 0
Views: 168
Reputation: 72
first i sort data in data grid through this function
public static function sortDataGrid(columnId:String , decending:Boolean , array:ArrayCollection):void
{
var sortThese:Sort = new Sort();
sortThese.fields = [new SortField(columnId, false, decending)];
array.sort = sortThese;
array.refresh();
}
then i Use this function for manually setting the required data on the first index.
public static function sortingNWFDataGrid(arrayCol:ArrayCollection):void
{
var currentIndx:Number = 0;
for(var i:int = 0 ; i < arrayCol.length; i++){
if(arrayCol.getItemAt(i).statusId == UserStatusConstants.NEW_STATUS_ID){
currentIndx = i;
break;
}
}
var newObj:Object = new Object();
newObj = arrayCol.getItemAt(currentIndx) as Object;
arrayCol.removeItemAt(currentIndx);
arrayCol.refresh();
arrayCol.addItemAt(newObj, 0);
arrayCol.refresh();
}
any one with better solution or with different approach please provide here.
Upvotes: 0