Sorting table by a hidden column

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Sorting table by a hidden column

Jonathan Wolfe
Hi,

I'm wondering if it's possible to sort a table column by another column when you click on the column header. Right now, I accomplish this by sorting a hidden column of date objects as the default setting for the table which works, but if a user clicks on the "Ends in" column header it reverts to alphanumeric sort which doesn't work too well in this case. So the user would have to show the "Ends at" column and then click it to sort it which isn't very intuitive. I envision a way to click on the column header and override the sort function to call the other columns sort method. Is this possible?




Jonathan Wolfe Meteorologist
Charleston Pilot Project  

Charleston, WV National Weather Service
304-746-0190

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Sorting table by a hidden column

Derrell Lipman
I think what you're looking for is custom sort methods. In the Simple table mode (qx.ui.table.model.Simple), the method setSortMethods is available:

    /**
     * Specify the methods to use for ascending and descending sorts of a
     * particular column.
     *
     * @param columnIndex {Integer}
     *   The index of the column for which the sort methods are being
     *   provided.
     *
     * @param compare {Function|Map}
     *   If provided as a Function, this is the comparator function to sort in
     *   ascending order. It takes two parameters: the two arrays of row data,
     *   row1 and row2, being compared. It may determine which column of the
     *   row data to sort on by accessing arguments.callee.columnIndex.  The
     *   comparator function must return 1, 0 or -1, when the column in row1
     *   is greater than, equal to, or less than, respectively, the column in
     *   row2.
     *
     *   If this parameter is a Map, it shall have two properties: "ascending"
     *   and "descending". The property value of each is a comparator
     *   function, as described above.
     *
     *   If only the "ascending" function is provided (i.e. this parameter is
     *   a Function, not a Map), then the "descending" function is built
     *   dynamically by passing the two parameters to the "ascending" function
     *   in reversed order. <i>Use of a dynamically-built "descending" function
     *   generates at least one extra function call for each row in the table,
     *   and possibly many more. If the table is expected to have more than
     *   about 1000 rows, you will likely want to provide a map with a custom
     *   "descending" sort function as well as the "ascending" one.</i>
     *
     */

Derrell



On Wed, Aug 20, 2014 at 10:16 AM, Jonathan Wolfe <[hidden email]> wrote:
Hi,

I'm wondering if it's possible to sort a table column by another column when you click on the column header. Right now, I accomplish this by sorting a hidden column of date objects as the default setting for the table which works, but if a user clicks on the "Ends in" column header it reverts to alphanumeric sort which doesn't work too well in this case. So the user would have to show the "Ends at" column and then click it to sort it which isn't very intuitive. I envision a way to click on the column header and override the sort function to call the other columns sort method. Is this possible?




Jonathan Wolfe Meteorologist
Charleston Pilot Project  

Charleston, WV National Weather Service
<a href="tel:304-746-0190" value="+13047460190" target="_blank">304-746-0190

------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Sorting table by a hidden column

Jonathan Wolfe
Thanks Derrell! That did it. :-)


Jonathan Wolfe Meteorologist
Charleston Pilot Project  

Charleston, WV National Weather Service
304-746-0190


On Wed, Aug 20, 2014 at 12:26 PM, Derrell Lipman <[hidden email]> wrote:
I think what you're looking for is custom sort methods. In the Simple table mode (qx.ui.table.model.Simple), the method setSortMethods is available:

    /**
     * Specify the methods to use for ascending and descending sorts of a
     * particular column.
     *
     * @param columnIndex {Integer}
     *   The index of the column for which the sort methods are being
     *   provided.
     *
     * @param compare {Function|Map}
     *   If provided as a Function, this is the comparator function to sort in
     *   ascending order. It takes two parameters: the two arrays of row data,
     *   row1 and row2, being compared. It may determine which column of the
     *   row data to sort on by accessing arguments.callee.columnIndex.  The
     *   comparator function must return 1, 0 or -1, when the column in row1
     *   is greater than, equal to, or less than, respectively, the column in
     *   row2.
     *
     *   If this parameter is a Map, it shall have two properties: "ascending"
     *   and "descending". The property value of each is a comparator
     *   function, as described above.
     *
     *   If only the "ascending" function is provided (i.e. this parameter is
     *   a Function, not a Map), then the "descending" function is built
     *   dynamically by passing the two parameters to the "ascending" function
     *   in reversed order. <i>Use of a dynamically-built "descending" function
     *   generates at least one extra function call for each row in the table,
     *   and possibly many more. If the table is expected to have more than
     *   about 1000 rows, you will likely want to provide a map with a custom
     *   "descending" sort function as well as the "ascending" one.</i>
     *
     */

Derrell



On Wed, Aug 20, 2014 at 10:16 AM, Jonathan Wolfe <[hidden email]> wrote:
Hi,

I'm wondering if it's possible to sort a table column by another column when you click on the column header. Right now, I accomplish this by sorting a hidden column of date objects as the default setting for the table which works, but if a user clicks on the "Ends in" column header it reverts to alphanumeric sort which doesn't work too well in this case. So the user would have to show the "Ends at" column and then click it to sort it which isn't very intuitive. I envision a way to click on the column header and override the sort function to call the other columns sort method. Is this possible?




Jonathan Wolfe Meteorologist
Charleston Pilot Project  

Charleston, WV National Weather Service
<a href="tel:304-746-0190" value="+13047460190" target="_blank">304-746-0190

------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel



------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel