arigs
asked on
multiple column sorting problem adg flex 4
Hi Experts,
I am trying to do multiple column sorting on adg. when i click in the header , the data getting sorted in reverse way. here is my code snippet.
private function sortSub(itemA:Object, itemB:Object):int
{
var messageA:MessagerVo = itemA as MessagerVo ;
var messageB:MessagerVo = itemB as MessagerVo ;
if(messageA.priority == messageB.priority)
{
var unReadA:int;
var unReadB:int;
if(messageA.unRead)
{
unReadA = 1;
}else{
unReadA = 0;
}
if(messageB.unRead)
{
unReadB = 1;// unread 1, read 0
}else{
unReadB = 0;// read
}
if(unReadA == unReadB)
{
return ObjectUtil.dateCompare(mes sageA.crea teDate,mes sageB.crea teDate);
}
return ObjectUtil.numericCompare( unReadA,un ReadB);
}
return ObjectUtil.numericCompare( int(messag eA.priorit y),int(mes sageB.prio rity));
}
I am trying to do multiple column sorting on adg. when i click in the header , the data getting sorted in reverse way. here is my code snippet.
private function sortSub(itemA:Object, itemB:Object):int
{
var messageA:MessagerVo = itemA as MessagerVo ;
var messageB:MessagerVo = itemB as MessagerVo ;
if(messageA.priority == messageB.priority)
{
var unReadA:int;
var unReadB:int;
if(messageA.unRead)
{
unReadA = 1;
}else{
unReadA = 0;
}
if(messageB.unRead)
{
unReadB = 1;// unread 1, read 0
}else{
unReadB = 0;// read
}
if(unReadA == unReadB)
{
return ObjectUtil.dateCompare(mes
}
return ObjectUtil.numericCompare(
}
return ObjectUtil.numericCompare(
}
Why are you not using sortExpertMode option
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
yeah I used it. I am able to do multiple sorting but what my problem is I could not display the data in correct order i.e for example if i put all messages with value 0 in objA and messages with value 1 in objB of one column..after clicking on header sorting should be done and dispalyed in correct order(i.e.if in objA the messages are in the order say 1 2 3 4 should be displayed in the same order 1 2 3 4 even after sorting)
ASKER
@dgofman:
If u dont mind can u be elaborate ? thx
If u dont mind can u be elaborate ? thx
I can but i need to get from you example of your object array and expecting result after applying a sorting
ASKER
message object contains a,b,c,d column fields and x,y,z values. in column a messages need to be sorted by x value.(x will have 0 and 1 ). when we click on header of column a, the other columns should also be sorted( column b and c should be sorted by their boolean values) and column d will be sorted by date values. thanks
ASKER
column d should be sorted according to the x values. i.e. dates belong to the x=0 as one object and other dates in other object.
I am still confused lets believe we have such data tell me how do you want to sort it?
df1 df2
1 a
5 e
2 b
4 d
3 c
df1 df2
1 a
5 e
2 b
4 d
3 c
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.