State maintenance in Vue Dashboard layout component

16 Mar 202311 minutes to read

The current layout structure of the Dashboard Layout component can be obtained and saved to construct another dashboard with same panel structure using the serialize public method of the component. This method returns the component’s current panel setting which can be used to construct a dashboard with the same layout settings.

The following sample demonstrates how to save and restore the state of the panels using the serialize method. Click Save to store the panel’s settings and click Restore to restore the previously saved panel settings.

        <div className="col-lg-8 control-section" id="control_dash">
            <div className="content-wrapper">
                <!--  DashboardLayout element declaration -->
                <ejs-dashboardlayout id='dashboard_default' ref="dashboard" :cellSpacing='cellSpacing' :columns="5" :created="onSave">
                        <e-panel :sizeX="1" :sizeY="1" :row="0" :col="0" content="<div class='content'>0</div>"></e-panel>
                        <e-panel :sizeX="3" :sizeY="2" :row="0" :col="1" content="<div class='content'>1</div>"></e-panel>
                        <e-panel :sizeX="1" :sizeY="3" :row="0" :col="4" content="<div class='content'>2</div>"></e-panel>
                        <e-panel :sizeX="1" :sizeY="1" :row="1" :col="0" content="<div class='content'>3</div>"></e-panel>
                        <e-panel :sizeX="2" :sizeY="1" :row="2" :col="0" content="<div class='content'>4</div>"></e-panel>
                        <e-panel :sizeX="1" :sizeY="1" :row="2" :col="2" content="<div class='content'>5</div>"></e-panel>  
                        <e-panel :sizeX="1" :sizeY="1" :row="2" :col="3" content="<div class='content'>6</div>"></e-panel>  
                <!-- end of dashboardlayout element -->
        <div className="col-lg-4 property-section dashboard" id="api_property">
            <div className="row property-panel-content">
                <div className="card-body">
                    <div className="form-group row">
                        <table id ="remove">
                                <tr><td> Properties Panel </td></tr>
                                        <!--  Button element declaration -->
                                        <ejs-button id="save" cssClass="e-primary"  v-on:click.native="onSave" >Save Panel</ejs-button>
                                        <!--  Button element declaration -->
                                        <ejs-button id="restore" cssClass="e-flat e-outline" v-on:click.native="onRestore">Restore Panel</ejs-button>

import Vue from "vue";
// Import syncfusion dashboardlayout component from layouts package
import { DashboardLayoutPlugin } from "@syncfusion/ej2-vue-layouts";
// Import syncfusion button component from buttons package
import { ButtonPlugin } from "@syncfusion/ej2-vue-buttons";


export default {
    data: function() {
        return {
            cellSpacing: [20, 20],
            restoreModel: []
    methods: {
        // Restore the initial panels
        onRestore: function(args) {
            // Create instances for dashboardlayout element
             this.$refs.dashboard.$el.ej2_instances[0].panels = this.$refs.restoreModel;

        // Save the current panels
        onSave: function(args) {
            // Create instances for dashboardlayout element
            this.$refs.restoreModel = this.$refs.dashboard.$el.ej2_instances[0].serialize();
            this.$refs.restoreModel[0].content = '<div class="content">0</div>';
            this.$refs.restoreModel[1].content = '<div class="content">1</div>';
            this.$refs.restoreModel[2].content = '<div class="content">2</div>';
            this.$refs.restoreModel[3].content = '<div class="content">3</div>';
            this.$refs.restoreModel[4].content = '<div class="content">4</div>';
            this.$refs.restoreModel[5].content = '<div class="content">5</div>';
            this.$refs.restoreModel[6].content = '<div class="content">6</div>';

@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-vue-layouts/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";

/* DashboardLayout element styles  */
#dashboard_default .e-panel .e-panel-content {
    vertical-align: middle;
    font-weight: 600;
    font-size: 20px;
    text-align: center;
    line-height: 100px;

#control_dash {
    display: block;
    width: 60%;
    float: left;

#api_property {
    display: inline-block;

#float_id {
    border: 1px solid black;

#remove {
    border: 1px solid black;

td {

#dashboard_default .e-panel {
  transition:none !important;

You can refer to our Vue Dashboard Layout feature tour page for its groundbreaking feature representations. You can also explore our Vue Dashboard Layout example to knows how to present and manipulate data.