简体   繁体   中英

How to set Column Priority in Kendo Grid

I'm using kendo grid and I've Columns array like below

 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.

Thanks in Advance!!!!

You are looking for reorderColumn(destIndex, object) event: reorderColumn .

  1. destIndex Number The new position of the column. 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.
$("#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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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