We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

State Maintenance of dashboard panels with template inside of them

I'm trying to make the position and the content of the panels persistent. So I looked at the page for the State Maintenace and then tried to replicate it but using templates as content instead of static html. But all the time, my panels are getting returned empty. This is what my code looks like:
const Position = this.$refs.dashboard.$el.ej2_instances[0].serialize();
Position[0][":content"] = "cTemplate(e)";

So I guess the cTemplate function is not returning value yet (it's inside the data) so it's returning nothing. Is there another way to do it?

3 Replies

AB Ashokkumar Balasubramanian Syncfusion Team October 7, 2019 11:16 AM UTC

Hi Matthieu, 
Good day to you. 
We have checked your reported query about state maintenance. You are able to maintain the state of dashboard layout panels using serialize() method.  In that method, you can get the dashboard layout panels element values such as position properties (row, column) and dimension properties (sizeX, sizeY). But the content of the dashboard layout panels needs to persist and update manually, because content value is not handled by component side. 
Refer the below code snippet to add the panel content manually to the dashboard layout. 
 // Save the current panels 
    onSave: function(args) { 
        // Create instances for dashboardlayout element 
        this.$refs.restoreModel = this.$refs.DashbordInstance.$el.ej2_instances[0].serialize(); 
        this.$refs.restoreModel[0].content = this.pie; 
        this.$refs.restoreModel[1].content = this.pieChart; 
        this.$refs.restoreModel[2].content = this.spline; 
For your reference we have prepared a simple sample. In that sample, we have rendered chart as a panel content and maintain the state of the panels using serialize() method. 
Refer the sample link below. 
Please let us know, if you have any concerns. 
Ashokkumar B. 

MA Matthieu October 7, 2019 04:17 PM UTC

Hi Ashokkumar,
Thanks for the help. I now got it working. Was close at the beginning, was just missing the "this" keyword before my function Template.

AB Ashokkumar Balasubramanian Syncfusion Team October 8, 2019 06:24 AM UTC

Hi Matthieu, 
We are glad to hear that the problem has been resolved. Please let us know, if you need any further assistance. 
Ashokkumar B. 

Live Chat Icon For mobile
Up arrow icon