Any way for numeric sorting of WebListBox columns in API 2?

The old API had great flexibility for sorting columns in a listbox. The new one seems to only offer two options: alphanumeric sort or no sort at all. Has anyone come up with an alternative?

1 Like

ColumsordirectionAt?

You can sort the weblistbox by column just as desktop. Or have the user press the header to sort it.

To set the column sortable:
http://documentation.xojo.com/api/user_interface/web/weblistbox.html#weblistbox-columnsorttypeat

Sort directions
http://documentation.xojo.com/api/user_interface/web/weblistbox.html#weblistbox-columnsortdirectionat

A-Z should mean ascending
Z-A should mean descending

Does that work for you?

What I want to sort are numbers and dates. These are sorted alphabetically so that

1,2,3,10,11,12 sorts as 1,10,11,12,2,3 which confuses my users. The same thing happens with dates. In the old system, you would display a date in standard mm/dd/yyyy format then store the SQLDate in a RowTag or CellTag and sort those. That functionality does not appear to be in the new API. Or have I missed something obvious?

1 Like

Apparently, the Targets is Web, not Windows.

Now, maybe in a future Xojo version, Web will add a Compare Event…

Maybe you may write a Feature request.

1 Like

Var RightStyle As New WebStyle
RightStyle.Bold = False
RightStyle.FontSize = 14
RightStyle.Value(“text-align”) = “Right”

Var LeftSpace As String = " " // 4 space character

Var buff As String = Mid(LeftSpace, 1, 5-rs.Column(“ID”).StringValue.Length)+rs.Column(“ID”).StringValue

Var cellRenderer As New WebListBoxStyleRenderer(RightStyle, buff)

ListBox1.CellValueAt(ListBox1.LastAddedRowIndex,0) = cellRenderer

Maintain an array of numbers that match a column in your list box. Sort the array and then refill the list box according to the array’s order

What did you end up doing? I’m attempting this for both numeric and date values as well. I can think of a few work arounds but none include using the column headers to sort (which is preferred).

I disabled sorting in numeric and date columns. If I could figure out which column header had been pressed, I would simply reload the listbox with a new sql statement with order by whatever was desired.

Yeah, I had the same idea. I went with a “filter” button, which opens a dialog box, allowing the user to select what fields to sort/filter.