Witam.
Mam pewien temat do rozwiązania odnośnie sortowania wierszy w tabeli. Znalazłem fajny skrypt w jQuery, który bardzo fajnie sortuje (dokładnie chodzi o sortowanie Connected lists with limited drop targets z poniższego linku)
https://johnny.github.io/jquery-sortable/
Wszystko działa super na zwykłej tabeli ale jak chcę podpiąć pod tabelę jTable, którą wziąłem ze strony www.jtable.org to skrypt ma problem. Przesuwa mi całą tabelę a nie poszczególne wiersze. Ktoś miał podobny problem lub potrafi mnie nakierować? Poniżej kod mojego JS
@section Scripts {
<script type="text/javascript">
$(document).ready(function () {
$('#table').jtable({
messages: @Html.ChangeLanguage(),
paging: true,
sorting: false,
pageSize: 999,
startIndex: 0,
actions: {
listAction: '@Url.Action("JSON", "Attr")'
},
fields: {
Id: {
key: true,
create: false,
edit: true,
list: false
},
Name: {
title: 'Nazwa',
width: '180px',
},
},
recordsLoaded: function (event, data) {
jTableRedirect(this, '@Url.Action("Index", "Attr")');
}
});
$('#table').jtable('load', {
});
var group = $('#table').sortable({
group: 'jtable-data-row',
isValidTarget: function ($item, container) {
return $item.parent("td")[0] == container.el[0];
},
onDrop: function ($item, container, _super) {
$('#serialize_output').text(
group.sortable("serialize").get().join("\n"));
_super($item, container);
},
serialize: function (parent, children, isContainer) {
return isContainer ? children.join() : parent.text();
},
tolerance: 6,
distance: 10
});
});
</script>
}