Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KendoUI Grid only allow sorting asc and desc with no unsorted allowed

I have a request to make my KendoUI Grid start with one column sorted, and from there only allow the column to have sorted asc and sorted desc options...meaning no unsorted option. What I mean is when page is first viewed, there is the icon that shows its sorted asc...and if the column header is clicked then it goes to sorted desc and then if clicked again it goes to sorted asc. Currently the default Kendo behavior is that the third click puts the grid in an unsorted mode with no sorted icon. If it helps, my code is below:

$("#grid").kendoGrid({
    dataSource: {
      data: carList,
      schema: {
         model: {
            fields: {
               "Car": { type: "number" },
               "Miles": { type: "number" }
            }
         }
      },
      sort: { field: "Miles", dir: "asc" }
    },
    height: 338,
    scrollable: true,
    sortable: true,
    filterable: false,
    pageable: false,
    columns: [
      {
         field: "Car",
         width: 40,
         sortable: true,
         hidden: false
      },
      {
         field: "Miles",
         width: 60,
         sortable: true,
         hidden: false
      }
    ]
    });
};

Does anyone know if there is a built-in way to achieve this toggle like effect? If not, any ideas on how to achieve this without having to totally write my own sort functions? Any ideas are great, thanks so much!

like image 536
t1nr2y Avatar asked Dec 26 '13 21:12

t1nr2y


1 Answers

I am just blind, there is a built in way...for others who may have missed it too:

sortable: {
  allowUnsort: false
}

Thanks so much!

like image 148
t1nr2y Avatar answered Sep 18 '22 20:09

t1nr2y