2017-07-21 15 views
0

に追加されます。btnSearchNameは検索結果のテーブルを含むモーダルを開き、選択する行ごとにチェックボックスを表示します。次にbtnSubmitをクリックすると、モーダルが閉じられ、選択したssn_or_tin 「123、645、936、743」のような入力フィールドの列は、私はすでに多くのコードを試みたが、動作していない、あなたはDataTableのOnrowboundを試すことができたJquery Datatables選択されたチェックボックスが入力フィールド

$('#btnSearchName').on("click", function() { 
    Namestable = $('#NamesDatatable').DataTable({ 
     "processing": true, 
     'select': { 
      'style': 'multi' 
     }, 
     'order': [[1, 'asc']], 
     dom: "<'row'<'col-sm-6'l><'col-sm-6'f>>" + 
      "<'row'<'col-sm-12'tr>>" + 
      "<'row'<'col-sm-6'i><'col-sm-6'p>>", 
     "ajax": { 
      "url": '/Home/GetAllCusname', 
      "type": "POST", 
      "datatype": "json", 
      "data": function (d) { 
       d.searchParameters = {}; 
       d.searchParameters.name = $('#txtName').val(); 
      } 
     }, 
     "columns": [ 
      { 
       defaultContent: '', 
       className: 'select-checkbox', 
       'checkboxes': { 
        'selectRow': true 
       }, 
       orderable: false 
      }, 
      { "data": "ssn_or_tin", "autoWidth": true }, 
      { "data": "name", "autoWidth": true } 
     ] 
    }); 
}); 

$('#btnSubmit').on("click", function() { 
    var rows_selected = Namestable.column(0).checkboxes.selected(); //i have not tested this line of code yet if it's working, 
          maybe there is another way of getting the selected checkbox, maybe by their class if they have the 'selected' class 

    $.each(rows_selected, function() { 
     $('#txtSSNTIN').append(
      //I don't know what code to put here, it must append the 
      'ssn_or_tin' values like '123, 953, 673' in the input field with 
      the id 'txtSSNTIN' 
     ); 
    }); 
}); 

答えて

0

を助けてください。これらを指定する必要はありません

+0

Jquery DataTablesでOnrowboundが見つかりません – Hanzou

関連する問題