- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
这是加入代码并分配Datatables
Route::get('Productos',function(){
$query = DB::table('producto as e')
->select('e.cod_producto', 'e.nom_producto', 'e.precio_venta', 'd.nombre as nombre_marca', 'j.nombre as nombre_tipo', DB::raw('if(e.estado = 0,\'Activo\',\'Eliminado\') as estado'))
->join('marca as d','e.cod_marca', '=', 'd.cod_marca')
->join('tipo-producto as j', 'e.cod_tipo_producto', '=', 'j.cod_tipo_producto');
return datatables()
->of($query)
->addColumn('btn','actions')
->rawColumns(['btn'])
->toJson();
});
这是 jQuery 代码
$(document).ready(function(){
$('#Productos').DataTable({
"bAutoWidth": false,
"destroy": true,
"responsive": true,
"serverSide":true,
"ajax":'{{url('api/Productos')}}',
"columnDefs": [ {
"targets": 'no-sort',
"orderable": false,
"searchable": false,
}],
"columns":[
{data: 'cod_producto'},
{data: 'nom_producto'},
{data: 'precio_venta'},
{data: 'nombre_marca'},
{data: 'nombre_tipo'},
{data: 'estado'},
{data: 'btn'},
]
});
});
现在,当我尝试搜索某些内容时,它会发出错误警报 这是一条错误消息
Exception Message:↵↵SQLSTATE[42000]: Syntax error or access violation: 1583 Incorrect parameters in the call to native function 'LOWER' (SQL: select count(*) as aggregate from (select '1' as
row_count
fromproducto
ase
inner joinmarca
asd
one
.cod_marca
=d
.cod_marca
inner jointipo-producto
asj
one
.cod_tipo_producto
=j
.cod_tipo_producto
where (LOWER(producto
ase.cod_producto
) LIKE %1% or LOWER(producto
ase.nom_producto
) LIKE %1% or LOWER(producto
ase.precio_venta
) LIKE %1% or LOWER(marca
.nombre
) LIKE %1% or LOWER(tipo-producto
.nombre
) LIKE %1% or LOWER(producto
ase.estado
) LIKE %1%)) count_row_table)
最佳答案
根据查询中的连接数据字段设置数据表列名称
这是示例
"columns":[
{data: 'cod_producto', name:'e.code_product'},
{data: 'nom_producto', name:'e.nom_producto'},
....
关于php - yajra/laravel-datatables 搜索不适用于 laravel 5.7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52618813/
我是一名优秀的程序员,十分优秀!