2017-09-25 39 views
2

THEAD值我用laravel 5.4刀片+數據表,我想用水泡編輯器(數據表),如例如在:https://editor.datatables.net/examples/bubble-editing/simple數據表自動獲取泡泡編輯器(Laravel +刀片)

,但我得到我的theads名從刀片而不是從json。我怎樣才能得到像那樣的泡泡編輯器?

<table id="main_grid" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%"> 
     <thead id='main_grid_thead'> 
      <tr> 
       @foreach($tablefields as $field) 
        <th>{{ $field['detail_field']['grid']['label'] }}</th> 
       @endforeach 
      </tr> 
     </thead> 
     <tbody> 
      <!-- TABLE BODY HERE--> 
     </tbody> 
    </table> 

,我得到了一個JS功能與數據表

var editor = new $.fn.dataTable.Editor({ 
     ajax: "../php/staff.php", 
     table: '#'+id_grid 
     }); 

    $('#'+id_grid).dataTable({ 
      sInfo: '', 
      "sDom": '<"html5buttons"B><"top"fZ>rt<"bottom"lpi><"clear"> ', 
      "oListNav": { 
        //SOME CODE 
      }, 
      pageLength: 10, 
      responsive: true, 

     }); 


    $('#' + id_grid).on('click', 'tbody td:not(:first-child)', function (e) { 
      editor.bubble($('#' + id_grid + ' tbody tr:first-child td:first-child')); 
     }); 

回答

1

我找到了解決辦法

$('#' + id_grid).on('click', 'tbody td i', function (e) { 
$(this).parent().children('i').attr('style','display:none; float: right;') 
    editor.bubble($(this).parent())