This is a migrated thread and some comments may be shown as answers.

How to save tilelayout and reload this in later

5 Answers 1403 Views
TileLayout
This is a migrated thread and some comments may be shown as answers.
duy
Top achievements
Rank 1
Veteran
duy asked on 17 Aug 2020, 07:36 AM

Hi !

I using telerik jquery , when i using tilelayout, i like action as : Drag, drop. 

 

But I want to save layout and reload it in later.

 

Please help me to do it !

 

tks !

5 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 19 Aug 2020, 07:32 AM

Hello Duy,

It is possible to save the TileLayout state to the local storage via getOptions and setOptions methods

//save the options
var options = $("#tilelayout").getKendoTileLayout().getOptions();
var stringOptions = JSON.stringify(options);
localStorage["kendo-tilelayout-options"] = stringOptions;
...
//  load the options
var options = localStorage["kendo-tilelayout-options"];
 if (options) {
      var deserializedOptions = JSON.parse(options, Function.deserialise);
      var layout = $("#tilelayout").getKendoTileLayout();
      layout.setOptions(deserializedOptions);
}

The above can be examined live in the following Dojo demo:

Let me know if you have any questions.

Regards,
Nikolay
Progress Telerik

Jimmy
Top achievements
Rank 1
Iron
Veteran
commented on 28 May 2021, 10:38 AM

HI

How do I save the order only without the template contents?

The contents is dynamic from database for each items. So I just need to restore the items order but load the contents from database.

Thank you.

Nikolay
Telerik team
commented on 01 Jun 2021, 07:49 AM

Hello Jimmy,

By design. the getOptions() method obtains the full options object. However, you can modify the options object before passing it to the setOptions() method.
The order or the tiles is positioned in containers.order and so you can modify the options object to use the order passed from the getOptions and use the database information for the rest of the containers data

Let me know if you have any questions.

Regards,

Nikolay

Jimmy
Top achievements
Rank 1
Iron
Veteran
commented on 01 Jun 2021, 08:29 AM

Thank you! Managed to save the order only.
Nikolay
Telerik team
commented on 03 Jun 2021, 06:20 AM

Hi Jimmy,

You are most welcome. I am glad to hear you have managed to resolve this and move on further.

Regards,

Nikolay

Venkat
Top achievements
Rank 1
commented on 27 Jul 2022, 03:49 AM

Hi Nikolay,

Can you provide sample code on how to retain order of the tiles only?

Nikolay
Telerik team
commented on 28 Jul 2022, 02:41 PM

Hi Venkat,

This could be done by just passing the TileLayout containers to localStorage instead of the whole option object:

$("#save").click(function (e) {
              e.preventDefault();
              var options = $("#tilelayout").getKendoTileLayout().getOptions();
              let containers = options.containers;
              localStorage.setItem("containers", JSON.stringify(containers));
            });

            $("#load").click(function (e) {
              e.preventDefault();
              var storedContainers = JSON.parse(localStorage.getItem("containers"),  Function.deserialise);
             
              if (storedContainers) {
                var layout = $("#tilelayout").getKendoTileLayout();
                layout.setOptions({
                  containers: storedContainers
                });
              }
            });

Dojo demo: https://dojo.telerik.com/APeriMIX/90

Regards,

Nikolay

 

0
duy
Top achievements
Rank 1
Veteran
answered on 19 Aug 2020, 10:21 AM

Oh. many thanks Nikolay !

 

This is correctly i find. But can you show me the documentation reference to do it.

I have read the document carefully but cannot find it.

Thanks you verry much !

0
Nikolay
Telerik team
answered on 21 Aug 2020, 09:21 AM

Hi Duy,

You are most welcome. 

Unfortunately, this is not present in the documentation, however, I will ensure it gets included as it is quite a valuable resource. Thank you for pointing it out.

Please contact us back if anything new arises.

Regards,
Nikolay
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Sri
Top achievements
Rank 1
answered on 05 Feb 2021, 08:26 PM
Does Kendo UI for Angular provides the same functionality (Saving the State)?
0
Nikolay
Telerik team
answered on 09 Feb 2021, 12:58 PM

Hello Sri K,

Are you referring to the Kendo UI library for Angular or it is for the TileLayout for AngularJS?

In case it is the latter the answer is yes and the logic for saving the tiles remains the same as it is in JavaScript.

For Kendo UI for Angular, I recommend submitting a thread to the respective forum as this is an entirely different product that I am not familiar with.

Regards,
Nikolay
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TileLayout
Asked by
duy
Top achievements
Rank 1
Veteran
Answers by
Nikolay
Telerik team
duy
Top achievements
Rank 1
Veteran
Sri
Top achievements
Rank 1
Share this question
or