HTML5 Data Bindings Support Product Page

Results from highest to lowest with groupBy(

Asked 10 Oct 2014 12:26:27
has this question
10 Oct 2014 12:26:27 Gianmario Colciago posted:
Good afternoon.
With the following code

<select name = "select" id = "select" 
data-binding-repeat-children = "{{ (& quot; year & quot;) .reverse ()}}" 
data-binding-id = "select" > 
 <option value = "{{$ name}}"> {{$ name}} </ option> 
 </ select> 

I would like to get the years with this order
2014- 2013-2012 ... and so on.

Instead, the result is the following
... 2012-2013-2014

Please, how can I achieve the desired result?


Replied 10 Oct 2014 15:34:59
10 Oct 2014 15:34:59 Teodor Kuduschiev replied:
How are those stored in your database? You can sort your query by ID, when creating it - so you can select ID - Descending order, this way the newer IDs will appear on top.
Replied 10 Oct 2014 18:37:41
10 Oct 2014 18:37:41 Gianmario Colciago replied:
The magazines are collected in this way in the test table MAGAZINES:


1 MAG1 2012
2 MAG2 2012
3 MAG3 2013
4 MAG4 2013
5 MAG5 2013
6 MAG6 2014
7 MAG7 2014

The YEAR field is sorted in descending order.

With the form SELECT I want to extract the years with groupBy() function and sort them in descending order.
The code is as follows:

<select name = "select" id = "select" 
data-binding-repeat-children = "{{ (& quot; year & quot;) .reverse ()}}" 
data-binding-id = "select"> 
<option value = "{{$name}}"> {{$name}} </ option> 
  </ Select>

Unfortunately, the years do not appear sorted in descending order even if I add the formatting function REVERSE ().

This code works correctly with PhpMyAdmin:

SELECT year 

Replied 14 Oct 2014 08:05:03
14 Oct 2014 08:05:03 Teodor Kuduschiev replied:
Hi Gianmario,
What i am saying is - just sort your datasource by ID in descending order:
This reply was removed on 10/14/2014 11:40:21 AM.
See the changelog
This reply was removed on 10/14/2014 11:42:29 AM.
See the changelog
Replied 14 Oct 2014 12:06:23
14 Oct 2014 12:06:23 Gianmario Colciago replied:
Hi Teodor!
I tried what you suggested me, but the result is not what I expect.
I am attaching PDF to show

1) the structure of the table
2) The definition of the datasource
3) The PHP file Datasource
4) the HTML file
5) The final result


Please, how can I attach a picture?
Replied 14 Oct 2014 12:12:00
14 Oct 2014 12:12:00 Teodor Kuduschiev replied:
Well then try to sort them by year, instead of ID.
Replied 17 Oct 2014 15:00:21
17 Oct 2014 15:00:21 Gianmario Colciago replied:
I had already tried this solution, but it does not work.
The data are grouped in ascending order, even though I set the YEAR field in descending order.
The data of the field YEAR appear correctly listed only in the test source in DataSource Query Builder, not with the function GroupBy ().
I did another check, but the result is always unsatisfactory.
Where is my error, if any? Thanks.
Replied 20 Oct 2014 08:37:59
20 Oct 2014 08:37:59 Teodor Kuduschiev replied:
Please provide a link to your page where i can check this.

Reply to this topic