简体   繁体   English

如何在不同领域对剑道网格进行排序?

[英]How to sort Kendo grid on different field?

I have a KenodGrid and I have field whose data is combination of two fields from the data. 我有一个KenodGrid,还有一个字段,其数据是数据中两个字段的组合。 How would I be able to sort the Column based on the data of one field. 如何根据一个字段的数据对列进行排序。 Here is the column I have: 这是我的专栏:

   {
            field: "Owner",
            filterable: false,
            sortable: true,

            template: function(data) {
                return data.OwnerFirstName + ' ' + data.OwnerLastName;
            }
        },

I want to sort the column on either OwnerFirstName or OwnerLastName but want to display both in the grid. 我想对OwnerFirstName或OwnerLastName上的列进行排序,但要在网格中同时显示两者。

You have to make it into 2 columns to be able to sort them apart : 您必须将其分成2列才能将它们分开:

            columns: [{
                field: "OwnerFirstName ",
                title: "Owner first name",
                filterable: false,
                sortable: true
            }, {
                field: "OwnerLastName",
                title: "Owner lastname",
                filterable: false,
                sortable: true
            }]

Kendo grid sort table based on defined field for the column in configuration, using a template doesn't effect it. Kendo网格排序表基于配置中列的已定义字段,使用模板不会对其产生影响。 So if you add OwnerFirstName or OwnerLastName to your column field it will sort it will sort your table perfectly. 因此,如果将OwnerFirstName或OwnerLastName添加到您的列字段中,它将对其进行排序,这将对您的表进行完美排序。

    columns: [
      { field: "OwnerFirstName",
       title:"owner",
            filterable: false,
            sortable: true,
            template: function(data) {
                return data.OwnerFirstName + ' ' + data.OwnerLastName;
            }
      },
    ....
  ]

Here is a working demo http://dojo.telerik.com/IPeVI 这是一个有效的演示http://dojo.telerik.com/IPeVI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM