I am attempting to use ag-grid's moveColumn API. Our grid has the following default state:
{
applyOrder: true,
defaultState: {hide: true} // <-- debugging suggest this is line of issues
}
This means for columns that do not have a hide prop, it will auto be set to false.
However, when I use moveColumn, the API counts to hidden columns in the index count. For example:
Data:
[
{
colid: 'Name',
hide: false,
pivot: false,
width: 100,
},
{
colid: 'Age',
hide: true,
pivot: false,
width: 100,
},
{
colid: 'Gender',
hide: true,
pivot: false,
width: 100,
},
{
colid: 'Height',
hide: true,
pivot: false,
width: 100,
},
{
colid: 'Eye Colour',
hide: false,
pivot: false,
width: 100,
},
{
colid: 'Hair Colour',
hide: false,
pivot: false,
width: 100,
},
]
If i call columnApi.moveColumn('Eye Colour', 3); i would expect Eye Colour to appear after the Hair Colour column given Age, Gender and Height are all set to hidden.
Note, if I remove defaultState: {hide: true} then all works as expected however it is quite important to have this to handle unknown columns.