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

Grid Sorting is empty on the third time

3 Answers 619 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alberto
Top achievements
Rank 1
Alberto asked on 05 Feb 2016, 05:04 PM

Hi All

 

I am using kendo UI 2016.1.112 with angular and I am having an issue with sorting, the first time e.data.sort is populated nicely with the field and direction , second time same field and direction as desc but clicking for third time get an empty array

     

     dataSource: {
        transport: {
            read: function (e) {
                if (!e.data.sort || e.data.sort.length === 0) {

                 ///WTH ..... WHY?

                }
                var sort = e.data.sort[0];
                exclusionsService.getExclusions(e.data.skip, e.data.take, sort.field, sort.dir).then(function (data) {
                    e.success(data);
                });
...

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 09 Feb 2016, 03:13 PM
Hello Alberto,

The observed behavior is expected - an empty array indicates that no sorting is currently applied.

Do you by any chance want the Grid to not allow unsorted mode?

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-sortable.allowUnsort

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alberto
Top achievements
Rank 1
answered on 09 Feb 2016, 04:57 PM

Hi Dimo

 

The first time works fine, then click on the column to apply sorting by descendant, then clicking on the same column I one to sort it back as ascendant but array is empty, that is not happening on the demo found here http://demos.telerik.com/kendo-ui/grid/angular,

In my code the maximum time I can click is twice.

 

 

0
Accepted
Dimo
Telerik team
answered on 11 Feb 2016, 04:43 PM
Hi Alberto,

I am not sure I understand. Please do the following:

1. Go to http://demos.telerik.com/kendo-ui/grid/angular
2. Execute the following code in the browser's JavaScript console:

$(".k-grid[options='mainGridOptions']").data("kendoGrid").dataSource.bind("requestStart", function(e) {
  console.log(e.sender.sort());
});

3. Click on any master Grid header cell to sort three times. You will see that the third time the sort method returns an empty array, which is normal, because the third time the column returns to unsorted state.

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-sort

Here is a video:

http://screencast.com/t/xqBfQvCC8Kiy

If you want the column to be sorted ascending the third time, then set the allowUnsort property, as suggested earlier.

Let me know if I am missing something.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Alberto
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Alberto
Top achievements
Rank 1
Share this question
or