Solution to keep the order numbers of selection (multiple)

Solution to keep the order numbers of selection (multiple)

tweetyjrtweetyjr Posts: 2Questions: 1Answers: 0

Hi,

Is my first question here, desperate one :)

Is it posible to keep the order number of multiple selection? Like in the photo below, I want my data after I select the rows in my table to be ordered as A, B, C, D, E. Now if I select A then select E, E became the first in my data object

Answers

  • kthorngrenkthorngren Posts: 21,182Questions: 26Answers: 4,925

    To make sure I understand the problem:

    Currently when you select a row the table order changes but you want it to always order by the second column. Is this correct?

    If so use order to define the initial table order. You can use columns.orderable to stop the user from ordering the checkbox column. Also you can use orderFixed to force the table to always order by the second column.

    If this doesn't help then please post a link to your page or a test case replicating the issue so we can offer suggestions.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • tweetyjrtweetyjr Posts: 2Questions: 1Answers: 0

    I think I've found a solution

    var dataForSubmit = [];
            table.on( 'select', function ( e, dt, type, indexes ) {
    
            if ( type === 'row' ) {
                var data = table.rows( indexes ).data();
                dataForSubmit.push(data);
            }
        } );
    

    And then iterate dataForSubmit in your click/event action. Seems very simple but figured hours to me to make it work

Sign In or Register to comment.