BS Table Repeat from a Data View: How to Sort on a DataView column?

Hey guys,

First time using DataView component to list records in a BS Table…
I have a serverconnect with a multi records query. Then I add a DataView and assign its Data Source to that query.


I’m trying to have my table data sorted on a DataView column by setting the DataView Sort on attribute sorton="ord_Total" (ord_Total is the DataView Column).

But it didn’t work like that, and my results were not correctly sorted (although Sort direction has an effect)

Here is a Ascending sort:
image

And here is Descending sort:
image

After a few tests I ended-up that the problem is if I assign a column type of Decimal.
If I sort on a Numeric or String type filed it is ok.

If anybody can give me an idea of what I’m doing wrong or how this can be handled it would be great.

Thanks in advance

It looks like ord_Total is a string rather than a number, hence the 1 comes first, then 30 then 38. You’ll need a column that is a number in order to sort properly.

1 Like

You’re right Ken,

That field although it is a decimal it appears as a string.

I have read that post Wappler return DECIMAL as TEXT and remembered that now you mention it…

I tried setting the Sort on to sorton="ord_Total.toNumber()" but no luck…
Unfortunately, in my case I cannot easily modify my server action because it is a complex one (paged query with a few joins(inner & left) and 2 level of nested subqueries and all of these with a complicated set of conditions based on $_GET parameters…)

So, there is no way of getting a proper sum on queries decimal columns?

Please somebody drop an idea here and save me from making all this ServerAction from scratch…

Try converting to a number in your table instead of your sort?

@brad I tried but nothing…

It is supposed that the source is getting sorted but I don’t know how to do it…

I found this excellent post here Sorting Bootstrap Table with App Connect API Data Source and I’m going to try it (don’t know how but I just can’t leave my statistics unsorted)…

Thanks guys for your reply!!

I think Server Array List is the only way to go…

So, I added a Repeat based on the query with the decimal Totals, and assigned all the original values from the query except the ord_Total that I assigned the ord_Total.toNumber().

And on client-side I set the DataView source to the ArrayList value ,instead of the original query …

Little more heavier for the server but works fine and no major handling changes on Client-Side.

1 Like