NGTi Data Grid restoreColumnState not always working

Hi,

Since moving from 2021.12 to 2024.9 the columnRestoreState() fails to restore the grid to the state it was in. I’m saving the grid state in a table in the onColumnStateChanged of the grid and restoring the grid settings in the onShow of forms. Have set the grid state as I want and saved and then disabled saving. After a grid has failed to restore the state correctly ig I log out and back into the solution the grid will restore correctly, so I am confident that the grid state has been saved correctly.

Have set the columnsAutoSizng to NONE and using the NG Grid Services set suppressAutoSize: true and suppressSizeToFit:true. With columnRestoreSate() have set the boolean options to true (even though that is the default) to true.

Any guidance on settings that work with columnRestoreState() will be greatly appreciated.

TIA

I did a quick test:

  • resized a column, saved the state from ‘onColumnStateChanged’;
  • set ‘columnAutoSizing’ to NONE
  • used the saved state to restore it via ‘restoreColumnState’ during the form’s ‘onShow’
    and I do see the size restored

can you create a case with the sample to show where it goes wrong for you?

Hi,

Updated to 2024.9.4 yesterday and the grids have kept their positions and widths so far. On the previous version by now they would have lost the stored position and width etc.

However on some forms we toggle the visible property, this no longer works, columns that have visible set to false when the form first shows when they are toggled to true they don’t display. If you check the property it is set to true and the column width is correct.

I quickly tried elements.datagrid.getColumn(0).visible = !elements.datagrid.getColumn(0).visible; and it works fine for me - can you create a case with a sample that shows the issue?

Hi,

if (sortOrder == “customer”) {
elements.orderList.columns[0].visible = false; //stock
elements.orderList.columns[1].visible = false; //grade
elements.orderList.columns[2].visible = false; //presentation
elements.orderList.columns[3].visible = true; //customer
elements.orderList.columns[4].visible = true; //route
} else {
elements.orderList.columns[0].visible = true; //stock
elements.orderList.columns[1].visible = true; //grade
elements.orderList.columns[2].visible = true; //presentation
elements.orderList.columns[3].visible = false; //customer
elements.orderList.columns[4].visible = true; //route
}

three more columns in the grid which are always visible.
sortOrder is set to ‘customer’ when form loads. Columns display as code 3, 4, 5, 6, 7 all visible.

button form to change sortOrder
0, 1 are not visible only 5,6 7.

change the sortOrder back to ‘customer’ 3, 4, 5, 6, 7 all visible.