Row select discrepancy

Row select discrepancy

Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2
edited May 2017 in Select

I have a custom button which looks like this:

{
     text : 'Edit',
     className : 'mRightFifteen',                
     action : function(e, dt, node, config) {
                            var enquiry_id = $.map(table.rows('.selected').data(), function (item) {
                                return item["enquiry"]["enquiry_id"];        
                            }).join( ',' );
                            sessionStorage.enquiry_ids = enquiry_id;
                            var create_date_timestamp = $.map(table.rows('.selected').data(), function (item) {
                                return item["enquiry"]["create_date_timestamp"];        
                            }).join( ',' );
                            sessionStorage.create_date_timestamps = create_date_timestamp;  
                            sessionStorage.count = table.rows('.selected').data().length;                                                      
                            $('#edit').attr('href', function() {
                                return this.href + '/team/';
                            });                    
                            $('#edit').trigger('click');
                            $('#edit').attr('href', '/');
     },
 },

There is a discrepancy between what the select-info information says and what is selected. By default page length is 50 but if I click select all then select-info says:

Showing 1 to 50 of 223 entries 223 rows selected

But table.rows('.selected').data().length; only says 50 rows are selected?

My table is setup to use server side.

Any ideas why the discrepancy and how to resolve it?

Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 54,578Questions: 1Answers: 8,533 Site admin
    Answer ✓

    What does:

    table.rows( { selected: true } ).count();
    

    say?

    Using .selected as a selector is only going to give you the rows which are visible when server-side processing. Using the selected modifier is the better way to get the selected rows.

    Having said that, it should still only be able to select the visible rows with server-side processing enabled.

    Allan

  • Restful Web ServicesRestful Web Services Posts: 202Questions: 49Answers: 2

    Hi Allan,

    That did the trick. Works as expected now, consistently across all areas.

    Thanks

    Chris

This discussion has been closed.