Hi,
Currently, once the filter is applied, the underlying values are changed for the cells and the original order cannot be restored.
However, you may do custom implementation and undo the changes to get back the original order. Kindly refer to the following code snippet and the sample:
let Commands = GC.Spread.Sheets.Commands;
let customSort = {
canUndo: true,
execute: function (spread, options, isUndo) {
if (isUndo) {
Commands.undoTransaction(spread, options);
return true;
} else {
Commands.startTransaction(spread, options);
let sheet = spread.getSheetFromName(options.sheetName);
const { rowIndex, colIndex, rowCount, colCount, ascending, index } = options;
console.log(sheet, rowIndex, colIndex, rowCount, colCount, ascending, index)
sheet.sortRange(
rowIndex, colIndex, rowCount, colCount,
true,
[
{
index: index,
ascending: ascending,
},
]
);
Commands.endTransaction(spread, options);
return true;
}
}
}
spread.commandManager().register("customSorting", customSort, null, false, false, false, false);
let clickCounts = {};
sheet.bind(GC.Spread.Sheets.Events.CellClick, (_sender, args) => {
if (args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader) {
const colIndex = args.col;
clickCounts[colIndex] = clickCounts[colIndex] || 0;
let rowCount = sheet.getRowCount();
let colCount = sheet.getColumnCount();
if (clickCounts[colIndex] === 0) {
spread.commandManager().execute({
cmd: "customSorting", sheetName: "Sheet1", rowIndex: 0, colIndex: 0,
rowCount: rowCount, colCount: colCount, ascending: true, index: args.col
});
} else if (clickCounts[colIndex] === 1) {
spread.commandManager().execute({
cmd: "customSorting", sheetName: "Sheet1", rowIndex: 0, colIndex: 0,
rowCount: rowCount, colCount: colCount, ascending: false, index: args.col
});
} else {
clickCounts[colIndex] = -1;
// Undo Two times;
spread.undoManager().undo();
spread.undoManager().undo();
}
clickCounts[colIndex]++;
}
});
Sample: https://jscodemine.grapecity.com/share/WjP267n5tkSPdsdjwleh1Q/?IsEmbed=false&Theme=Unset&PreviewDirection=0&IsEditorShow=true&IsExplorerShow=true&IsPreviewShow=true&IsConsoleShow=true&IsRunBTNShow=false&IsResetBTNShow=false&IsOpenInCodemineBTNShow=false&PanelWidth=20&PanelWidth=50&PanelWidth=30&defaultOpen={"OpenedFileName"%3A["%2Fsrc%2Fapp.js"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.js"}
However, this is just a custom solution. If you apply the Row Filter on Excel also, you cannot revert back to original order. Similarly, you could do your custom implementation.
References:
Undo Manager Demo: https://developer.mescius.com/spreadjs/demos/features/worksheet/actions/undo-manager#demo_source_name
Custom Actions: https://developer.mescius.com/spreadjs/demos/features/worksheet/actions/custom-action/purejs
Regards,
Ankit