Kendo DataSource()排序多个字段

时间:2017-02-22 10:36:54

标签: kendo-ui

我试图将我的数据源排序为多个字段,但它不起作用。 这是我的代码:

var dataSource = new kendo.data.DataSource({
    transport: {
        read: notifURL
    },
    pageSize: 30,
    sort: [{ field: "ID", dir: "desc" },
            { field: "Time", dir: "desc" }]
});

1 个答案:

答案 0 :(得分:0)

答案是here

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Tea", category: "Beverages" },
    { name: "Coffee", category: "Beverages" },
    { name: "Ham", category: "Food" }
  ],
  sort: [
    // sort by "category" in descending order and then by "name" in ascending order
    { field: "category", dir: "desc" },
    { field: "name", dir: "asc" }
  ]
});
dataSource.fetch(function(){
  var data = dataSource.view();
  console.log(data[1].name); // displays "Coffee"
});
</script>