2017-07-17 3 views
0

私は自分のプロジェクトでdataTableを使用しました。編集と削除のボタンを使ってカスタム列を追加しました。私は機能するために個々のフィールドを渡すことができます。関数への引数としてオブジェクトを渡すことは可能ですか?以下はDatatableのデータをボタンクリック機能のあるメソッドに渡すことはできますか

私のdataTableコードです:

<script type="text/javascript"> 
    var table1; 
    $(function(){ 

     table1 = $('#simpletable').DataTable({ 
     processing :true, 
     serverSide :true, 
     //table: '#simpletable', 
     ajax :"{{route('shippingPreference.create')}}", 
     columns :[ 

     // { data: "id" }, 
     { data: "channel_name" }, 
     { data: "process_type" }, 
     { data: "method_name" }, 
     { data: "market_place_shipping_method_name" }, 
     { 
      sortable: false, 
      "render": function (data, type, full, meta) { 
       console.log(full); 
       var actionhtml='<button data-toggle="tooltip" data-placement="top" id="'+full.id+'" title="Remove" type="button" class="btn btn-danger btn-xs" >' + 
        '<i class="fa fa-times-circle" aria-hidden="true"></i></button><a data-toggle="tooltip" data-placement="top" data-original-title="Edit" class="btn btn-info btn-xs" onclick="callMe('+full+')">'+ 
        '<i class="fa fa-edit" aria-hidden="true"></i></a>'; 
       return actionhtml; 
      } 
     } 
    ], 
    }); 
}); 
+0

を上記のコード? – markpsmith

+0

それはエラーを返します。未定義です。 –

答えて

0

@markpsmithが語ったとおり、あなたがJSON.stringify(full)を使用して、単一引用符の代わりに、あなたのコード内の二重引用符を使用する必要があります:あなたが実行したときに何が起こる

var actionhtml='<button data-toggle="tooltip" data-placement="top" id="'+full.id+'" title="Remove" type="button" class="btn btn-danger btn-xs" >' + 
        '<i class="fa fa-times-circle" aria-hidden="true"></i></button><a data-toggle="tooltip" data-placement="top" data-original-title="Edit" class="btn btn-info btn-xs" onclick=\'callMe('+JSON.stringify(full)+')\'>'+ 
        '<i class="fa fa-edit" aria-hidden="true"></i></a>'; 
関連する問題