How to sort a cursor ?

Roger Amar Roger at logram.com
Tue Feb 22 13:45:46 CST 2005


Hello Robert,

Thank you.
I know how to sort fields with Revolution.
However, when fields are sorted, the cursor is not, and you can't use navigation arrows to move into.
I also often use SQLSelectRecords to get a list in place of a cursor ref.
As about buttons as column headings,  I reproduced in fact a listManager list with headings which are more convenient and more ergonomic to sort lists than clicking the field.

At this time, the main problem which is remaining is the fact that I cannot import anything on the pc.
Did you try to do it ?

Best regards,

Roger;



-----Message d'origine-----
De : valentina-bounces at lists.macserve.net [mailto:valentina-bounces at lists.macserve.net] De la part de Robert Brenstein
Envoyé : mardi 22 février 2005 00:00
À : Valentina Developers
Objet : RE: How to sort a cursor ?

>I am using one main cursor for each table. When I want to use it, I 
>just put its ref into CursorRef.
>Let us say one of the cursors ref is "cursor1Ref".
>My column headings are made of buttons used to sort the columns.
>I must create a cursor with every sort to have the navigation arrows 
>working properly.
>
>To do that, I must :
>(cursor1Ref is put into cursorRef)
>
>1 - ask for the sql string of cursor1Ref
>2 - change the "order by" in the sql
>3 - remove the cursor - because Valentina does not let me create a 
>cursor with the same query even with a different name.
>4 - create a new cursor
>5 - save its value into cursor1Ref
>6 - put it into CursorRef.
>
>Maybe I am doing things in a complicated manner ?
>Please let me know.
>Roger;

This of course all depends on the data and program specifics, but in general, you can use SqlSelectRecords instead of SqlSelect, so you have all your display data in a variable, global or local, so it persists.

put Valentina("Database_SqlSelectoRecords",dbRef,query) into displayList

Then clicking any sort button calls a card handler that redisplays that variable after sorting it by a specific column.

on displaySorted sortColumn,sortType
   set the itemDelimiter to tab
   sort lines of displayList sortType by item sortColumn of each
   put displayList into fld "xyz"
end displaySorted

This is generally simpler than using multiple SQL queries and managing cursors. This also reduces shuffling data through valentina external which ads some pverhead by having to convert values to proper types.

BTW, you don't have to use buttons as column headings to achieve the above. You can have a text field and check the clickcharchunk to figure which header (field item) was clicked, then sort accordingly and underline that header to indicate sorting column by setting the textstyle of that item.

Robert
_______________________________________________
Valentina mailing list
Valentina at lists.macserve.net
http://lists.macserve.net/mailman/listinfo/valentina





More information about the Valentina mailing list