Theme: Popup:

Grid maintain selection after reaload

In this demo the selected items are being reselected after grid reload, providing that after reload the grid still contains the previously selected items.
To try it select a few items and after click on the grid refresh button or on the current page.
    <%:Html.Awe().Grid("MealsGrid")
.Url(Url.Action("MealsGrid"))
.HtmlAttributes(new { data_mw="200"})
.Selectable(SelectionType.Multicheck)
.Columns(new Column{ Name = "Name"})
%>

<script>
$(function () {
var lastSelectedIds;
$('#MealsGrid').on('aweselect', function () {
lastSelectedIds = $.map($(this).data('api').getSelection(), function (val) { return val.Id; });
});

$('#MealsGrid').on('aweload', function () {
if (lastSelectedIds) {
$(this).find('.awe-row').each(function (i, row) {
if ($.inArray($(row).data('model').Id, lastSelectedIds) > -1) {
$(row).addClass('awe-selected');
}
}).trigger('aweselect');
}
});
});
</script>