'Remove filter's label in Backpack for Laravel
Does someone know in which file exactly can I delete the filter result label at the list view? For example, say that I have a list of teams, and in each team, I also have a list of users. I want to filter out the users that are not inside the team's menu that I'm visiting right now. So i use $this->crud->addClause() method provided by Backpack. What I don't want is that after the filter has run, it shows me the Showing 1 to 1 of 1 entry (filtered from 4 total entries). Reset label. Of course, I don't want my user to know how many users I'm having inside my DB(you can see it from the filtered from 4 total entries label), that's why I want to remove that label. Does anyone know how to do that? Thanks. By the way, here's the label located :
Solution 1:[1]
you could hide it using something like:
@push('after_scripts')
<script>
$(document).ready(function () {
$(".dataTables_info").hide()});
</script>
@endpush
add the previous code to the end of your resources/views/vendor/backpack/base/inc/topbar_right_content.blade.php file
it will hide the overall statistics ..
Solution 2:[2]
Internally, Backpack use DataTables for CRUDs list operations. Looking at DataTable's documentation, there's an option to disable the records count / filtered records info.
Backpack's DataTable is setup in datatables_logic.blade.php which is located at /vendor/backpack/crud/src/resources/views/crud/inc
If a blade file with the exact name exists in resources/views/vendor/backpack/crud folder, Backpack will pick up that instead, so all you have to do is
Copy the original datatables_logic.blade.php into WhateverYourAppNameIs/resources/views/vendor/backpack/crud/inc/datatables_logic.blade.php
Edit the file & locate this (around line 88)
dataTableConfiguration: { @if ($crud->getResponsiveTable())
And change it into this
dataTableConfiguration: {
"info": false,
@if ($crud->getResponsiveTable())
That's it. Filtered records count is gone.
Solution 3:[3]
If you just want to hide the filtered from 4 total entries label
Do what @rbndeveloper had mention to copy the datatables_logic.blade.php
Inside the file do the below changes.
go to
"infoFiltered": "{{ trans('backpack::crud.infoFiltered') }}",
change to
"infoFiltered": "",
You have to the total record removed.
Solution 4:[4]
You can overwrite the ListOperation::search() method in your EntityCrudController and change like this:
Instead of
$totalRows = $this->crud->model->count();
Write
$totalRows = $this->crud->count();
Now you'll only see the line
"Showing x to x of x entries"
.
and
"filtered from x total entries"
will be removed now because the total records are equal to the fetched records.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | OMR |
| Solution 2 | Dharman |
| Solution 3 | Shiro |
| Solution 4 | Tayyab Yasin |
