bllim / laravel4-datatables-package - >从查询中获取id

时间:2013-12-29 07:21:03

标签: laravel-4 datatables

我在尝试使用edit_column时从查询中获取ID,但我只是为了' id'专栏,当我试图将其用于'操作'专栏我得到了' id'的html标记。列。

以下是代码:

public function ajaxGetAllPages()
{
    $pages = Page::select(array('id','title','updated_at','status'));
    return Datatables::of($pages)
    ->edit_column('id', '<input type="checkbox" class="checkboxes tooltips" value="{{ $id }}" data-placement="left" data-original-title="&nbsp;אינדקס # {{ $id }}&nbsp;" />')
    ->edit_column('title','<a href="{{ URL::route( \'admin.pages.index\') }}">{{ $title }}</a>')
    ->edit_column('updated_at', '{{ date("d-m-Y | H:i",strtotime($updated_at)) }}')
    ->edit_column('status', '{{ $status }}')
    ->edit_column('operations',
                    '<a href="#" data-id="{{ $id }}" class="btn btn-xs blue btn-editable tooltips" data-placement="top" data-original-title="עריכה"><i class="fa fa-pencil"></i></a>
                     <a href="#" data-id="{{ $id }}" class="btn btn-xs dark btn-trash tooltips" data-placement="top" data-original-title="לארכיון"><i class="fa fa-trash-o"></i></a>
                     <a href="#" data-id="{{ $id }}" class="btn btn-xs red btn-removable tooltips" data-placement="top" data-original-title="מחיקה"><i class="fa fa-times"></i></a>
                     <div class="btn-group">
                        <button class="btn default btn-xs dropdown-toggle" type="button" data-toggle="dropdown">עוד <i class="fa fa-angle-down"></i></button>
                        <ul class="dropdown-menu pull-right" role="menu">
                            <li><a href="#">פעולה</a></li>
                            <li><a href="#">פעולה</a></li>
                        </ul>
                     </div>'
    )
    ->make();
}

标记结果 - http://screencast.com/t/nIefrpqc8

我做错了什么还是错误?

谢谢, 陈

1 个答案:

答案 0 :(得分:0)

根据Bllim文档:

If you use double quotes while giving content of add_column or edit_column, you should escape variables with backslash () else you get error. For example:

edit_column('id',"- {{ \$id }}") 

在$ id之前使用反斜杠。

->edit_column('operations',
                    '<a href="#" data-id="{{ \$id }}" class="btn btn-xs blue btn-editable tooltips" data-placement="top" data-original-title="עריכה"><i class="fa fa-pencil"></i></a>
                     <a href="#" data-id="{{ \$id }}" class="btn btn-xs dark btn-trash tooltips" data-placement="top" data-original-title="לארכיון"><i class="fa fa-trash-o"></i></a>
                     <a href="#" data-id="{{ \$id }}" class="btn btn-xs red btn-removable tooltips" data-placement="top" data-original-title="מחיקה"><i class="fa fa-times"></i></a>
                     <div class="btn-group">
                        <button class="btn default btn-xs dropdown-toggle" type="button" data-toggle="dropdown">עוד <i class="fa fa-angle-down"></i></button>
                        <ul class="dropdown-menu pull-right" role="menu">
                            <li><a href="#">פעולה</a></li>
                            <li><a href="#">פעולה</a></li>
                        </ul>
                     </div>'
    )