This is a migrated thread and some comments may be shown as answers.

Server Sorting

5 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott Rakestraw
Top achievements
Rank 1
Scott Rakestraw asked on 03 Jan 2012, 05:38 PM
I have server sorting working but when I set allowUnsort to true it will always pass in the last sort when clicking on a column for the third time.  So it goes asc, desc, then the it appears to not be sorting on anything but it is actually still passing in the desc sort to the webservice.

5 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 04 Jan 2012, 10:00 AM
Hello Scott,

I'm afraid that I'm unable to recreate such behavior locally. Therefore it will be appreciated if you could provide a small sample in which  this could be observed.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Scott Rakestraw
Top achievements
Rank 1
answered on 06 Jan 2012, 08:55 PM
Just an update to this, I don't have an example but I do see when I debug the kendo js in query: function(options) that options.sort contains one item with the correct column name and a dir of undefined.  I'm not sure if that is normal behavior or is a symptom of the problem.
0
Scott Rakestraw
Top achievements
Rank 1
answered on 06 Jan 2012, 10:21 PM
I also noticed for paging I don't have to setup my data call to pass in take, skip etc they are automatically appended but if I don't setup up sort as a parameter it does not get added on the initial call.
0
Rosen
Telerik team
answered on 09 Jan 2012, 01:02 PM
Hi,

Indeed, the sort with field name and empty direction is valid and after processing the descriptor should be ignored and not passed to the server.
Note that you may reassign the names of the parameters send to the server by using transport's parameterMap function as shown in the documentation.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jignesh
Top achievements
Rank 1
answered on 01 Mar 2012, 07:28 AM
Hello,

Solution:
var dataSource = new kendo.data.DataSource({
     transport
: {
       read
: "Catalog/Titles",
       parameterMap
: function(options) {
         
return {
             pageIndex
: options.page,
             size
: options.pageSize,
             orderBy
: convertSort(options.sort)
         
}
       
}
     
}
 
}); var prevSort = ""; function convertSort(sort) {
        if (sort != null) {
            if (sort[0].dir == "desc") {
                if (prevSort == "desc")
                    sort[0].dir = "new";
                else
                    sort[0].dir = "desc";
            }
            prevSort = sort[0].dir;
            return sort;
        }
        return null;
    }

Thanks,
Jignesh Ramavat
Tags
Grid
Asked by
Scott Rakestraw
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Scott Rakestraw
Top achievements
Rank 1
Jignesh
Top achievements
Rank 1
Share this question
or