jQuery JTable how to drag rows

2019-07-26 07:41发布

I would like to drag rows in a table build with jQuery jTable, on release update sort order with ajax call. Is that possible?

Can't find anything about draggable rows

1条回答
萌系小妹纸
2楼-- · 2019-07-26 08:15

i found a solution bind the query ui on recordsLoaded, call each time record are loaded

   $('#mytable').jtable({
        title: 'my title',
        paging: true,
        pageSize: 100,
        sorting: true,
        defaultSorting: 'order ASC',
        selecting: true,
        multiselect: true,
        selectingCheckboxes: true,
        columnSelectable: false,
        gotoPageArea: 'none',
        pageSizeChangeArea: false,
        actions: {
            listAction: '../ajax/myajax.php'
        },
        fields: {
            id: {
                key: true,
                create: false,
                edit: false,
                list: false
            },
            order: {
                title: 'order',
                create: false,
                edit: false,
                sorting: false
            }
        },
        recordsLoaded: function () {

            $(".jtable tbody").sortable({
                cursor: 'move',
                opacity: 0.9,
                axis: 'y',
                start: function (event, ui) {
                    if ($.browser.webkit) {
                        wscrolltop = $(window).scrollTop(); // bug fix
                    }
                },
                sort: function (event, ui) {
                    if ($.browser.webkit) {
                        ui.helper.css({ 'top': ui.position.top + wscrolltop + 'px' });  // bug fix
                    }
                },
                update: function(event, ui) {

                    // do jquery HERE on sort

                }

            }).disableSelection();

        }
    });
查看更多
登录 后发表回答