【问题标题】:Kendo Grid wouldn't sort when using Key/Value pair array object使用键/值对数组对象时,Kendo Grid 不会排序
【发布时间】:2015-10-07 08:39:51
【问题描述】:

我正在使用 Telerik Kendo Grid;当我的数据源(数组)如下所示时,它不允许使用表的可排序功能:

var myArray = [

{ Destination = { Country: "United Kingdom", AircraftTypeCount: 9 }, Origin= [ {​Country: "United States", Code: "JFK"} ] },

{ Destination = { Country: "Egypt", AircraftTypeCount: ​5 }, Origin= [ {​Country: "​Qatar", Code: "QR"} ] }]

它可以很好地呈现国家/地区列,但是当我单击该列时,不会发生排序。下面是我的剑道网格(使用 AngularJS):

        $("#myKendoTable").kendoGrid({
            dataSource: {
                data: myArray                    
            },
            sortable: {
                mode: "multiple",
                allowUnsort: true
            },
            columns: [
                {
                    field: "Country",
                    title: "Country",
                    width: 300,
                    template: function (item) {
                        return item["Destination"].Country;
                    }
                }
            ]
        });

【问题讨论】:

    标签: sorting kendo-ui grid


    【解决方案1】:

    我刚刚解决了这个问题。似乎 Kendo 的排序功能可以识别基本的数组结构,所以我将 myArray 中的所有 Destinations 检索到一个单独的数组中,并将该新数组用作数据源。

    我使用了以下方法(使用 underscoreJS):

    函数 getDestinationsData(airlineRoutes) { return _.map(AirlineDestinationRoutes, function (airlineRoutes) { return airportRoutes.Destination }); }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 2020-02-26
      相关资源
      最近更新 更多