Kendo Grids Column Reordering with Column templates

1 Answer 22 Views
Grid Templates
Naima
Top achievements
Rank 1
Iron
Naima asked on 19 Feb 2025, 11:07 PM | edited on 20 Feb 2025, 01:46 PM

I am having an issue when I attempt to reorder the columns in my kendo grid and save the state. I am able to get the column order saved after reordering and then reloaded correctly in the updated order, but the issue is that only the column headers are responding to the reorder not the column content especially when the column contains a columnTemplate. How do I ensure that when I reorder my columns, that the column content and column headers are both reordered, and my column content is not mismatched to an incorrect column header on reload or lost due to unexpected behavior. For context I am using this method to reset the column order after its saved and reloaded

  reorderColumns(grid: kendo.ui.Grid, order: any) {
    var columns = grid.columns;
    for (var i = 0; i < order.length; i++) {
      var field = order[i];
      var currentIndex = -1;
      var targetIndex = i;

      for (var j = 0; j < columns.length; j++) {
        if (columns[j].field === field) {
          currentIndex = j;
          break;
        }
      }
      if (currentIndex !== -1 && currentIndex !== targetIndex) {
        grid.reorderColumn(currentIndex, targetIndex);
      }

    }
  }

1 Answer, 1 is accepted

Sort by
0
Naima
Top achievements
Rank 1
Iron
answered on 20 Feb 2025, 04:13 PM
please disregard this issue was a result of some custom functionality within my project 
Tags
Grid Templates
Asked by
Naima
Top achievements
Rank 1
Iron
Answers by
Naima
Top achievements
Rank 1
Iron
Share this question
or