Serialization is a process of converting an object into a stream of bytes. The stream of bytes can be stored or transmitted into memory, a database, or a file. The main purpose of serialization is to save the state of the object.
DataViewsJS includes serialization for all grid and layout engine options. You can store a data view in a JSON object which can be loaded into another view.
Use the following steps to implement serialization.
These steps assume that you have already initialized the grid and defined the columns. See Creating a Basic Grid and Defining Columns for additional information.
<div class="setting-container">
<button id="serialize" class="serialize-setting btn btn-default">Serialize</button>
</div>
<div id="grid1" class="grid"></div>
<div id="grid2" class="grid">
<div class="inner-container">
<div class="inner-text">Serialized Grid</div>
</div>
</div>
document.querySelector('#grid1').focus();
var dataView2;
$('#serialize').click(function () {
if (dataView2) {
dataView2.destroy();
dataView2 = null;
}
var container = document.getElementById('grid2');
container.innerHTML = '';
dataView2 = new GC.DataViews.DataView(container, data, dataView1.toJSON());
});
Submit and view feedback for