data_table: initialize sort_order correctly
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 2 Oct 2023 10:35:45 +0000 (12:35 +0200)
committerDominik Csapak <d.csapak@proxmox.com>
Mon, 2 Oct 2023 10:35:45 +0000 (12:35 +0200)
by picking up the column sort order during initialization.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
src/widget/data_table/header_state.rs

index d3024336f686fe2d54a6d8a072f0519653ca6101..7e9e2550dfa071b43ab9218b64ef6d95f7191e44 100644 (file)
@@ -36,9 +36,13 @@ impl<T: 'static> HeaderState<T> {
         }
 
         let mut cell_state = Vec::new();
+        let mut sort_order = Vec::new();
         for cell in cell_map.iter() {
             match cell {
                 IndexedHeader::Single(cell) => {
+                    if cell.column.sort_order.is_some() {
+                        sort_order.push(cell_state.len());
+                    }
                     cell_state.push(CellState {
                         width: None,
                         hidden: cell.column.hidden,
@@ -66,7 +70,7 @@ impl<T: 'static> HeaderState<T> {
             columns,
             cell_map,
             cell_state,
-            sort_order: Vec::new(),
+            sort_order,
         }
     }