I'm trying to implement ordering functionality in datatable. Requirement is simple, when a user drag a row for repositioning the respective row position/order field value should be incremented/decremented respectively in database!

I tried the below but sortable function is just fetching the 1st 10 entries ids from the DataTable in parameters variable.

How can I get all the available entries ids from the datatable in my params variable. The DataTable is in paginated form so I want to get all the records ids in parameters variable when someone is reordering records in DataTable.

// The below functionality is for ordering categories
var $sortable = $( ".resources-categories-table > tbody" );
$sortable.sortable({
    stop: function ( event, ui ) {
        var parameters = $sortable.sortable( "toArray", { attribute: 'data-id' });
        $.ajax({
            url: '<?php echo $this->CxHelper->Route('eb-admin-change-resource-category-order')?>',
            type: 'POST',
            data: { values: parameters },
            success: function (data) {
                cx.common.data.cxAdminDataTables.ResourceCategory.cxAdminDataTable("reloadAjax");
            }
        });
    }
});

PHP:

public function changeResourceCategoryOrderAction() {
    $values = $this->request->get( 'values', null );
    var_dump($values);exit;
}

0 Answers