保留折叠一组列的列顺序的正确方法是什么?
What is the proper way to preserve column order collapsing a group of columns?
使用 ag-grid 列在组内移动 (https://www.ag-grid.com/javascript-grid-column-moving/) works as intended, but after collapsing this group order is not preserved, initial first column is shown, not the first column after the move. You can see it as default behavior (https://www.ag-grid.com/example.php). Column API method setColumnGroupOpened
is used for expand / collapse of a group (you can find it here https://www.ag-grid.com/javascript-grid-column-api/)。
步骤:
有一组列
通过移动特征(通过拖放或 api)将第一列替换为第二列
收起这个群组
你可以在官方例子中复现https://www.ag-grid.com/example.php。
实际结果:显示初始第一列,而不是移动的列。
期望的结果:折叠后显示移动一列。
可能的解决方案很少,但它们似乎令人怀疑并且不是很干净。可能有一个算法以需要的方式改变列或组定义 columnGroupShow
字段。该字段记录在此处:https://www.ag-grid.com/javascript-grid-column-properties/。该算法可以在 columnnMoved
或展开/折叠事件上执行。具有保留顺序的列应该参与此操作。用于此目的的列 API 方法是 getAllGridColumns
。将它与事件负载一起使用变得不是很方便,应该检查树中的所有列,并且应该在需要的地方更新 columnGroupShow
字段。
达到这种行为的正确/推荐方法是什么?
最后,达到这种行为的唯一可能方法是为不同的列改变列 属性 columnGroupShow
。
使用 ag-grid 列在组内移动 (https://www.ag-grid.com/javascript-grid-column-moving/) works as intended, but after collapsing this group order is not preserved, initial first column is shown, not the first column after the move. You can see it as default behavior (https://www.ag-grid.com/example.php). Column API method setColumnGroupOpened
is used for expand / collapse of a group (you can find it here https://www.ag-grid.com/javascript-grid-column-api/)。
步骤:
有一组列
通过移动特征(通过拖放或 api)将第一列替换为第二列
收起这个群组
你可以在官方例子中复现https://www.ag-grid.com/example.php。
实际结果:显示初始第一列,而不是移动的列。
期望的结果:折叠后显示移动一列。
可能的解决方案很少,但它们似乎令人怀疑并且不是很干净。可能有一个算法以需要的方式改变列或组定义 columnGroupShow
字段。该字段记录在此处:https://www.ag-grid.com/javascript-grid-column-properties/。该算法可以在 columnnMoved
或展开/折叠事件上执行。具有保留顺序的列应该参与此操作。用于此目的的列 API 方法是 getAllGridColumns
。将它与事件负载一起使用变得不是很方便,应该检查树中的所有列,并且应该在需要的地方更新 columnGroupShow
字段。
达到这种行为的正确/推荐方法是什么?
最后,达到这种行为的唯一可能方法是为不同的列改变列 属性 columnGroupShow
。