Rollback
When first importing a dataset using the loadData() function, etc., or at a specific point in time (savePoint) after the dataset is changed, a complete copy of the dataset stored in the DataProvider is saved separately and the DataProvider is later restored (rollback) with these values. You can do it.
Data restoration function
The rollback function restores the DataProvider using the data copy saved with savePoint.
When data is restored to a specified savePoint
, subsequent DataProvider savePoints will be deleted.
The initially replicated dataset can be restored using rollBack, but cannot be deleted, so it is deleted using DataProvider clearSavePoints.
If savePoint
is not specified, it will be restored to the original replication.
//Create savePoint
dataProvider.savePoint(true);
//rollback
dataProvider.rollback(savePoint);
//savePoint initialization
dataProvider.clearSavePoints();
Restoring data
- Restore DataProvider to a specific savePoint.
- All clones created after the specified savePoint are removed.
- Call clearSavePoints() to delete all replications, including the first replication.
//Create a restore point
$('#btnSavePoint').click(function() {
gridView.cancel();
dataProvider.savePoint($("#chkStates").is(":checked"));
refreshPoints();
});
//Restore data
$('#btnRollBack').click(function() {
var point = $("#listPoints").val();
gridView.cancel();
dataProvider.rollback(point); // If point is omitted, restore to original replication
refreshPoints();
});
//savePoint initialization
$('#btnClearPoints').click(function() {
dataProvider.clearSavePoints();
refreshPoints();
});
function refreshPoints() {
var points = dataProvider.getSavePoints();
var list = $("#listPoints");
list.empty();
$.map(points, function (c) {
$("<option />", { value: c, text: "savePoint_" + c }).appendTo(list);
});
}