-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
float/integer number cannot be searched in filter search box after upgraded to version ^10.0 #106
Comments
Thanks for prompt feedback! Any chance to fix it on v10? Else I need to upgrade to laravel 11 with yajra/datatables v11 too. Thanks |
Can you provide some snippets to reproduce the issue? Are you using collection or query/eloquent builder? |
"laravel/framework": "^10.0", //javascript file setup
|
JS looks fine, how about the php code? |
$draw = $request->get('draw');
$start = $request->get("start");
$rowperpage = $request->get("length"); // Rows display per page
$columnIndex_arr = $request->get('order');
$columnName_arr = $request->get('columns');
$order_arr = $request->get('order');
$search_arr = $request->get('search');
$columnIndex = $columnIndex_arr[0]['column']; // Column index
$columnName = $columnName_arr[$columnIndex]['data']; // Column name
$columnSortOrder = $order_arr[0]['dir']; // asc or desc
$searchValue = $search_arr['value']; // Search value
$submission_rs = DB::table('invoices')
->select('invoices.*');
$total_rec = $submission_rs->count();
if ($searchValue!=""){
$submission_rs
-> where(function($query) use ($searchValue) {
$query-> orwhere('invoices.company_name', 'like', '%' .$searchValue . '%')
-> orwhere('invoices.invoice_no', 'like', '%' .$searchValue . '%')
-> orwhere('invoices.receipt_no', 'like', '%' .$searchValue . '%')
-> orwhere('invoices.price', 'like', '%' .$searchValue . '%')
-> orwhere('invoices.earlybird_discount', 'like', '%' .$searchValue . '%')
-> orwhere('invoices.discount', 'like', '%' .$searchValue . '%')
-> orwhere('invoices.total_amount', 'like', '%' .$searchValue . '%')
-> orwhere('invoices.status', 'like', '%' .$searchValue . '%')
-> orwhere('invoices.payment_method', 'like', '%' .$searchValue . '%')
-> orwhere('invoices.receipt_str', 'like', '%' .$searchValue . '%')
-> orwhere('invoices.received_amount', 'like', '%' .$searchValue . '%');
});
}
$total_rec_filter = $submission_rs->count();
$submission_rs -> skip($start)
-> take ($rowperpage)
-> orderBy($columnName,$columnSortOrder);
$submission_rs_array = $submission_rs->get();
$datatable_output = Datatables::of($submission_rs_array)
->addColumn('action', function($row){
$outbody = '<div class="btn-group">';
//some button actions
$outbody.= '</div>';
$actionBtn = $outbody;
return $actionBtn;
})
->rawColumns(['action'])
->setTotalRecords($total_rec)
->setFilteredRecords($total_rec_filter)
->skipPaging()
->smart(false)
->make(true);
return $datatable_output; |
It appears that you are using collection thus 4800 != 4,800. I suggest you query instead and let the package handle the pagination, search, sort, and counting. Something like: $submission_rs = DB::table('invoices')
->select('invoices.*');
$datatable_output = Datatables::of($submission_rs_array)
->addColumn('action', function($row){
$outbody = '<div class="btn-group">';
//some button actions
$outbody.= '</div>';
$actionBtn = $outbody;
return $actionBtn;
})
->rawColumns(['action'])
->smart(false)
->make(true);
return $datatable_output; |
Dear Bro I tried to remove the formatter in js file: Also, just using your suggestion that let the package handle the functions: However, the issue still occurs, only the number cannot be searched. BTW, thanks for your support! Best |
before upgraded to 10.0, the float / integer number can be searched.
The text was updated successfully, but these errors were encountered: