Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

Sorting items – PB Docs 2022 – PowerBuilder Library

Sorting items – PB Docs 2022

Sorting items

A TreeView can sort items automatically, or you can control
sorting manually. Manual sorting can be alphabetic by label text, or you
can implement a user-defined sort to define your own criteria. The
SortType property controls the way items are sorted. Its values are of
the enumerated datatype grSortType.

Automatic alphabetic
sorting

To enable sorting by the text label, set the SortType property to
Ascending! or Descending!. Inserted items are sorted
automatically.

Manual alphabetic sorting

For more control over sorting, you can set SortType to
Unsorted! and sort by calling the functions in the following
table.

Use this function

To do this

InsertItemSort

Insert an item at the correct alphabetic position,
if possible

Sort

Sort the immediate children of an
item

SortAll

Sort the whole branch below an item

If users will drag items to organize the list, you should disable
sorting.

Sorting by other criteria

To sort items by criteria other than their labels, implement a
user-defined sort by setting the SortType property to
UserDefinedSort! and writing a script for the Sort event. The script
specifies how to sort items.

PowerBuilder triggers the Sort event for each pair of items it
tries to reorder. The Sort script returns a value reporting which item
is greater than the other. The script can have different rules for
sorting based on the type of item. For example, level 2 items can be
sorted differently from level 3. The TreeView is sorted whenever you
insert an item.

Example of Sort event

This sample script for the Sort event sorts the first level by the
value of the Data property and other levels alphabetically by their
labels. The first level displays composers chronologically, and the Data
property contains an integer identifying a composer’s century:


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x