Multi row select on different pages

Multi row select on different pages

jLinuxjLinux Posts: 981Questions: 73Answers: 75

Im using the TableTools multi-row select (http://datatables.net/release-datatables/extensions/TableTools/examples/select_multi.html) to select which rows to perform an action on. The problem is, if the display limit is set to 5, and theres 3 tables, and rows are selected on different display pages, then they wont all be found when searching for them. im assuming this is because they arent found in the DOM?

Just for testing, I was executing - $('#data-table').find('tbody').find('tr.active').length; - to see if I get all thats selected... no dice.

Whats the correct way of doing it? I know i could probably just add/delete the row ID from an array every time selected/deselected, but thats kind of a band-aid, I would think theres a more efficient way of doing it

Thanks!... again

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited July 2015

    And to answer my own question -> http://datatables.net/extensions/tabletools/api#fnGetSelectedData

    Edit: However, the row ID is in the <tr> tag, how can I get my hands on that? it doesnt seem accessible via fnGetSelectedData()
    http://d.pr/i/11l2g

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Think I got it, let me know if this is the most efficient way:

    var $assets_table = TableTools.fnGetInstance( 'data-table' );
                                var $selected_rows = $assets_table.fnGetSelectedData();
                                var count = $selected_rows.length;
    
                                var rows = $assets_table.fnGetSelected();
    
                                $.each(rows, function(i,v){
                                    console.log('data:', v.attributes['data-row-id' ].value);
                                });
    
This discussion has been closed.