javascript - Multiple Datatables with Multiselect -


after 2 days of searching , trying fix problem, don't know how continue.

i use datatables numerous plugins, extensions , custom code intern webapplication. have problem select-extension datatables (https://datatables.net/extensions/select/). use extension custom-code found online enable user multiselect rows out of table , use ids of rows after submiting form table within. works charm.

for new module need use multiple tables in 1 form , need value of every selected row every table. rows first table picked up, each table after ignored.

i wrote light-version of script in jsfiddle. can't find reason why doesn't work on jsfiddle, code same use on our module works: https://jsfiddle.net/wgeh64vp/

var table = $('.table_select').datatable( {     'initcomplete': function(){     var api = this.api();      api         .rows()             .every(function(){            var data = this.data();            if(data[1] === '1'){               api.cells(this.index(), 0).checkboxes.select();            }         });     },     order: [[2, "asc"]],     paging:false,     info:false,     filter:false,     language: {         "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/german.json",     },     columns: [         null,         { "visible": false},         null     ],     'columndefs': [{         'targets': 0,         'checkboxes': {             'selectrow': true,             'selectall': false         }     }],     select: {         style: 'multi'     } });  $('.select_table_form').on('submit', function(e){   var form = this;    var rows_selected = table.column(0).checkboxes.selected();    // iterate on selected checkboxes   $.each(rows_selected, function(index, rowid){      // create hidden element       $(form).append(          $('<input>')             .attr('type', 'hidden')             .attr('name', 'select_values[]')             .val(rowid)      );   }); }); 

at moment every value every selected row of first table written in $_post['select_values'][].

how can selected rows tables in post-variables? if possible, prefer array each table selected rows tables.

edit 16.11.2016:

i tried tweak little bit of jquery-code tutorials found online. sadly still doesn't work, it's pretty sure wrong here. maybe sees anything? problem seems jquery-part of script...

    $('.table_select').datatable( {     'initcomplete': function(){     var api = this.api();      api         .rows()             .every(function(){            var data = this.data();            if(data[1] === '1'){               api.cells(this.index(), 0).checkboxes.select();            }         });     },     order: [[2, "asc"]],     paging:false,     info:false,     filter:false,     language: {         "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/german.json",     },     columns: [         null,         { "visible": false},         null     ],     'columndefs': [{         'targets': 0,         'checkboxes': {             'selectrow': true,             'selectall': false         }     }],     select: {         style: 'multi'     } });   var $table = $('.table_select');  $('.select_table_form').on('submit', function(e){     var form = this;      $table.each( function(i) {        var rows_selected = this.column(0).checkboxes.selected();        // iterate on selected checkboxes       $.each(rows_selected, function(index, rowid){          // create hidden element           $(form).append(              $('<input>')                 .attr('type', 'hidden')                 .attr('name', 'select_values[]')                 .val(rowid)          );       });     }); }); 


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -