Sorting an EditableListView

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Sorting an EditableListView

Louis Sumberg-2
I'm trying to implement a primary and secondary sort using an
EditableListView.  With a regular ListView, for the column I want to sort,
I'd do something like leave the getContents aspect as nil, set the
getTextBlock aspect to call the accessor I want, and set the sortBlock
aspect to something like [:a :b | a primaryAspect = b primaryAspect ifTrue:
[a secondaryAspect] ifFalse: [a primaryAspect]].  However, this approach
doesn't seem to work.  In addition, I don't understand the difference
between the sortBlock and getSortContents aspects.  I really like the
EditableListView and various embedded editors.  Can anyone shed light on how
to do the sort and how these various aspects are used?

-- Louis


Reply | Threaded
Open this post in threaded view
|

Re: Sorting an EditableListView

Yar Hwee Boon-3
On Thu, 30 Sep 2004 01:55:41 -0700, Louis Sumberg  
<[hidden email]> wrote:

> [a secondaryAspect] ifFalse: [a primaryAspect]].  However, this approach
> doesn't seem to work.  In addition, I don't understand the difference
> between the sortBlock and getSortContents aspects.  I really like the
> EditableListView and various embedded editors.  Can anyone shed light on  
> how
> to do the sort and how these various aspects are used?

How does the sorting not work? It seems OK for me. Could it be you did a  
"a primaryAspect = b primaryAspect" (note the = instead of inequality).

#sortBlock is passed 2 values. If #getSortContentsBlock is not provided,  
the 2 values are the results from #getContentsBlock, otherwise the results  
 from #getSortContentsBlock are used. Basically it lets you choose to  
either use the column's object for sorting or some other object.

--
Regards
HweeBoon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: Sorting an EditableListView

Louis Sumberg-2
HweeBoon,

> #sortBlock is passed 2 values. If #getSortContentsBlock is not provided,
> the 2 values are the results from #getContentsBlock, otherwise the results
>  from #getSortContentsBlock are used. Basically it lets you choose to
> either use the column's object for sorting or some other object.

Thank you, thank you.  It works great now :)  The key thing (for me) was the
use of #getSortContentsBlock and that it is used _with_ #getContentsBlock
(i.e., they are not mutually exclusive), which might seem obvious now, but I
guess it wasn't obvious when I was wrestling with this.  All I had to do was
specify the #getSortContentsBlock (i.e., [:a | a]).  In fact, with this
implementation, it's not even necessary to use #getTextBlock to do a
multiple sort.

-- Louis