Angular : DevExtreme DataGrid State Storing
I'm using the DevExtreme DataGrid widget under my Angular app.
here is the view of my datGrid:
<dx-data-grid
id="gridContainer"
[dataSource]="employees"
[allowColumnReordering]="true"
[allowColumnResizing]="true"
[columnAutoWidth]="true">
<dxo-column-chooser [enabled]="true"></dxo-column-chooser>
<dxo-column-fixing [enabled]="true"></dxo-column-fixing>
<dxo-state-storing [enabled]="true" type="custom" savingTimeout="2000" [customSave]="tableStateSave" [customLoad]="tableStateLoad"></dxo-state-storing>
<dxi-column
caption="Employee"
[width]="230"
[fixed]="true"
[calculateCellValue]="calculateCellValue"
></dxi-column>
<dxi-column dataField="BirthDate" dataType="date"></dxi-column>
<dxi-column dataField="HireDate" dataType="date"></dxi-column>
<dxi-column dataField="Position" alignment="right"></dxi-column>
<dxi-column dataField="Address" [width]="230"></dxi-column>
<dxi-column dataField="City"></dxi-column>
<dxi-column dataField="Zipcode" [visible]="false"></dxi-column>
<dxi-column dataField="HomePhone"></dxi-column>
<dxi-column dataField="MobilePhone"></dxi-column>
<dxi-column dataField="Skype"></dxi-column>
<dxi-column dataField="Email"></dxi-column>
</dx-data-grid>
As you cas see in this line :
<dxo-state-storing [enabled]="true" type="custom" savingTimeout="2000" [customSave]="tableStateSave" [customLoad]="tableStateLoad"></dxo-state-storing>
I'm using custom methods to load (tableStateLoad) and save (tableStateSave) my DataGrid state (columns positions and sizes).
State saving is done after every changing action automatically within a timeout of 2 seconds.
But i wanna replace this automated saving action by a manual one with a simple button .
Suggestions ??
You could use the dxo-state-storing
directive without specifying a custom save method:
<dxo-state-storing [enabled]="true" type="custom" savingTimeout="2000" [customLoad]="tableStateLoad"></dxo-state-storing>
or just set the customSave
property to an empty function. That way the state gets automatically loaded, but is not saved in any way. Then you implement a button that has a click handler with your custom saving logic, accessing the current grid's state with grid.instance.state()
.
上一篇: 将变量转移到另一个视图