2017-09-25 68 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())