how can I get the depot number against checkbox selected

how can I get the depot number against checkbox selected

polachanpolachan Posts: 101Questions: 50Answers: 0
edited November 2019 in Free community support

I have given my sample code link below. I want to get all the depotno which have been selected into the string variable inside the function CloseDepot() , Please help
https://jsfiddle.net/wqcLzdam/

Answers

  • rf1234rf1234 Posts: 2,941Questions: 87Answers: 415
    edited November 2019

    Your code confuses me a little ... Looks like you are not really using the built-in features of Editor and Data Tables a lot.

    You want to be able to select a number of rows and then do something with the selected rows. For that reason you want to put the ids (or something else?) of these rows into a string.

    Ok, I have something similar. I am using Data Tables Select extension which is really valuable here and "on select" of one or multiple rows I fill an array of something with more values if they aren't in the array yet. That should be pretty much the same as you would require, I guess.

    So this is part of the data table definition. Including the settings for the select extension (style: 'os' etc.) and the "on select" event handler that fills my two arrays with data from the selected data table rows.

    https://datatables.net/extensions/select/

    var acctSystems = [];
    var acctSystemProviders = [];
    
    var table = $('#table').DataTable( {
        dom: "Bfrltip",
        ajax: {
            url: 'actions.php?action=whatever'
        },
        columns: [
            ...................       
            {   data: "table.acct_system"  },
            {   data: "table.acct_system_provider"  },
            ..........
        ],        
        select: {
            style: 'os',
            selector: 'td:not(:first-child)' // no row selection on first column
        },    
        buttons: [        
                    {extend: "editSettings", editor: someEditor}, 
                        "selectAll",
                        "colvis"
        ]
    } );
    
    table.on ( 'select', function (e, dt, type, indexes) {
        acctSystems = [];
        acctSystemProviders = [];
        dt.rows({ selected: true }).every( function ( rowIdx, tableLoop, rowLoop ) {
            var data = this.data();
            if ( acctSystems.indexOf(data.table.acct_system) < 0 ) {
                acctSystems.push(data.table.acct_system);
            }
            if ( acctSystemProviders.indexOf(data.table.acct_system_provider) < 0 ) {
                acctSystemProviders.push(data.table.acct_system_provider);
            }
        });
    })     
    
This discussion has been closed.