Hi,
I was hoping someone could help me with the issue I have in storing the order of sortable panels within the local storage.
Here is some example code I am using:
-----------------------------------------------------------------------------------------
.........
string name = string.Format("main-content{0}", colCounter);
<div id = "@name" >
@{
foreach (var colItem in cols)
{
@renderTiles(colItem);
}
}
</div>
..................
@(Html.Kendo().Sortable()
.For("#main-content1")
.ConnectWith("#main-content2,#main-content3")
.Cursor("move")
.PlaceholderHandler("placeholder")
.HintHandler("hint")
)
@(Html.Kendo().Sortable()
.For("#main-content2")
.ConnectWith("#main-content1,#main-content3")
.Cursor("move")
.PlaceholderHandler("placeholder")
.HintHandler("hint")
)
@(Html.Kendo().Sortable()
.For("#main-content3")
.ConnectWith("#main-content1, #main-content2")
.Cursor("move")
.PlaceholderHandler("placeholder")
.HintHandler("hint")
)
.............
<script>
var localStorageSupport = (('localStorage' in window && window['localStorage'] !== null)),
data,
html;
if (localStorageSupport) {
data = JSON.parse(localStorage.getItem("sortableData"));
} else {
alert("your browser does not support local storage");
}
$(document).ready(function ()
{
$('.widget').click(function (e) {
window.location.href = $(e.target).attr('href');
})
$('.widget').change(function (e) {
var item = data.splice(e.oldIndex, 1)[0];
data.splice(e.newIndex, 0, item);
localStorage.setItem("sortableData", kendo.stringify(data))
})
})
</script>
@helper renderTiles(IPublishedContent Section)
{
var title = Section.GetPropertyValue<string>("tiitle", String.Empty);
var icon = Section.GetPropertyValue<string>("icon", String.Empty);
int intLink = Section.GetPropertyValue<int>("intLink", 0);
var extLink = Section.GetPropertyValue<string>("extLink", String.Empty);
var imgId = Section.GetPropertyValue("icon", -1);
var Url = string.Empty;
if (@intLink == 0 && @extLink.Length > 0)
{
Url = @extLink;
}
else if (@intLink != 0 && @extLink.Length == 0)
{
Url = Umbraco.NiceUrl(@intLink);
}
<div id="panes" class="widget" header="@title" href="@Url">
<div header="@title" href="@Url">
@title
<div class="widget-image" header="@title" href="@Url">
@if (imgId != -1)
{
<img src="@Umbraco.TypedMedia(imgId).Url" alt="=@Umbraco.TypedMedia(imgId).Name" title="@title" header="@title" href="@Url" />
}
</div>
</div>
</div>
}
I have looked at the following:
http://docs.telerik.com/kendo-ui/controls/interactivity/sortable/overview
http://docs.telerik.com/kendo-ui/controls/interactivity/sortable/how-to/persist-order-in-localstorage
http://www.telerik.com/forums/saving-sortable-state
These do make sense but I am having a bit of a senior moment with what I am trying to do.
Many thanks.
J