简体   繁体   English

如何在 Kendo Grid 中设置列优先级

[英]How to set Column Priority in Kendo Grid

I'm using kendo grid and I've Columns array like below我正在使用剑道网格,并且我有如下所示的 Columns 数组

 columns: [
            {
                field: "Column1",
                title: "Column 1",
                width: "120px"
            },
            {
                field: "Column2",
                title: "Column 2",
                width: "120px"
            },
            {
                field: "Column3",
                title: "Column 3",
                width: "160px"
            },
            .
            .
            .
          ]

How to set the order of the columns display in kendo grid or Is it possible any other way?如何设置在剑道网格中显示的列顺序,或者是否有其他方式? Like 1st Column2 and then Column3 and then Column1 need to be displayed.就像需要显示第一个 Column2 然后 Column3 然后 Column1 一样。

Thanks in Advance!!!!提前致谢!!!!

You are looking for reorderColumn(destIndex, object) event: reorderColumn .您正在寻找reorderColumn(destIndex, object)事件: reorderColumn

  1. destIndex Number The new position of the column. destIndex Number列的新 position。 The destination index should be calculated with regard to all columns, including the hidden ones.应针对所有列(包括隐藏列)计算目标索引。
  1. column Object The column whose position should be changed.Object应更改 position 的列。
$("#grid").kendoGrid({
  columns: [
    { field: "name" },
    { field: "age" }
  ],
  dataSource: [
      { name: "Jane Doe", age: 30 },
      { name: "John Doe", age: 33 }
  ]
});
var grid = $("#grid").data("kendoGrid");

//your logic for calcualting destination index and column
grid.reorderColumn(1, grid.columns[0]);

Offical example: reorderColumn官方示例: reorderColumn

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

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