That should be fixed in an upcoming release to tapestry-jquery.  I worked with 
Demey from their team to get that resolved, he just needs to check in and push 
the fix.

-----Original Message-----
From: mwrohde [mailto:mro...@navicure.com]
Sent: Wednesday, January 23, 2013 12:32 PM
To: users@tapestry.apache.org
Subject: Jquery Datatable ajax'd sort reverses

I've been struggling with the jquery datatable.  I've been on this thread with 
some server side pagination and sorting:
http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-td5715816.html
<http://tapestry.1045711.n5.nabble.com/ANN-JumpStart-gets-jQuery-DataTables-example-td5715816.html>

I've got that working-ish.  My code correctly interprets what tapesty and the 
jquery tapestry code tells me is the sort column and order.  However, what 
tapestry is telling me and what jquery is sending don't match.

If I render my page then select a column heading to sort by, jquery recognizes 
it, tapesty tells me, and all is good.  If I then click "Next" or another page 
number, tapestry reverses the sort.  If I click next again, tapestry again 
reverses the sort, back to the original.

However, if click a column heading to sort by, wait for that page to
(correctly) render, then refresh my browser page, I can then click forward and 
backward to my heart's content and the sort order remains constant and correct.

Here, I think, is the relevent got5 code, with some comments of mine inline.
DefaultDataTable
        public void prepareResponse(GridDataSource source){

                String sortingCols =
request.getParameter(DataTableConstants.SORTING_COLS);

                if(InternalUtils.isNonBlank(sortingCols)){
                        int nbSortingCols = Integer.parseInt(sortingCols);

                        String sord = 
request.getParameter(DataTableConstants.SORT_DIR+"0");

                        String sidx = 
request.getParameter(DataTableConstants.SORT_COL+"0");

                        /// nbSortingCols is, in fact, greater than zero.
jquery sent "iSortingCols    1".  I assume this means we are sorting on one,
and only one, column/
                        if(nbSortingCols>0)
                        {
                                List<String> names = model.getPropertyNames();

                                int indexProperty = Integer.parseInt(sidx);

                                String propName = names.get(indexProperty);

                                ColumnSort colSort 
=sortModel.getColumnSort(propName);

                                sortModel.updateSort(propName);  /// <-- This 
guy reverses the sort./
                        }
                }

        }

AbstractTable
                public void updateSort(String columnId) {
                        assert InternalUtils.isNonBlank(columnId);
                        if (columnId.equals(sortColumnId)) {  /// If we're 
sorting on this column, reverse the sort/
                                setSortAscending(!getSortAscending());
                                return;
                        }

                        sortColumnId = columnId;
                        setSortAscending(true);
                }

I understand that this code is reversing the sort if jquery sends iSortingCols 
with a value of greater than zero.  However, the jquery documentation indicates 
that it *is* going to send that if we're sorting on
something:  /The following information is sent to the server for each draw 
request. Your server-side script must use this information to obtain the data 
required for the draw." and it includes iSortingCols in that list./ Relevent 
jquery page <http://datatables.net/usage/server-side>

I do not understand why refreshing the browser page stops this behavior.

More importantly, I don't know what I should to get it to behave correctly 
without the browser refresh.  Thank you in advance for your help.

Matt




--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Jquery-Datatable-ajax-d-sort-reverses-tp5719457.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


Since 1982, Starpoint Solutions has been a trusted source of human capital and 
solutions. We are committed to our clients, employees, environment, community 
and social concerns.  We foster an inclusive culture based on trust, respect, 
honesty and solid performance. Learn more about Starpoint and our social 
responsibility at http://www.starpoint.com/social_responsibility

This email message from Starpoint Solutions LLC is for the sole use of  the 
intended recipient(s) and may contain confidential and privileged  information. 
 Any unauthorized review, use, disclosure or distribution is prohibited.  If 
you are not the intended recipient, please contact the sender by reply email 
and destroy all copies of the original message.  Opinions, conclusions and 
other information in this message that do not relate to the official business 
of Starpoint Solutions shall be understood as neither given nor endorsed by it.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to