doudouchan5830
2015-03-03 10:04
浏览 83
已采纳

如何在laravel 4.2的数据表中添加编辑/删除按钮?

I used laravel 4.2 billam Server side Datatable, and now it' works. But I can't add Edit and Remove Button in this datatable.

View page :

 <script type="text/javascript">
var oTable;
$(document).ready(function() {
    oTable = $('#tasks').dataTable( {
        "sPaginationType": "bootstrap",
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "{{ URL::to('/task') }}"
    });
});

Route :

Route::get('/task',function(){
$posts = Campaigns::select(array('title','created_at','status'));
 return Datatables::of($posts)
 ->make();
});

Now how can I add Delete and edit button ? I am follow there documentation from here that not works for me.

Documented Example 2: Adding and editing columns

->add_column('operations', '<a href="{{ URL::route( \'admin.post\', array( \'edit\',$id )) }}">edit</a>
                <a href="{{ URL::route( \'admin.post\', array( \'delete\',$id )) }}">delete</a>
            ')
->edit_column('status', '{{ $status ? 'Active' : 'Passive' }}')
->edit_column('ownername', function($row) {
    return "The author of this post is {$row->ownername}";
})

But how can I use blade structured code in route or controller? it's make little confusion..

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题