Comments (2)
Hi, here's a piece of code. Keep in mind that this is only a guideline.
Take a look at https://symfony.com/bundles/EasyAdminBundle/current/design.html#overriding-templates for more information.
//YourCrudController
#[\Override]
public function configureCrud(Crud $crud): Crud
{
return $crud
->overrideTemplate('crud/index', 'admin/index/my_index.html.twig')
;
}
//templates/admin/index/my_index.html.twig
This a copy of \vendor\easycorp\easyadmin-bundle\src\Resources\views\crud\index.html.twig
I removed all blocks except {% block table_body %}
commented code with (!!) I added on the fly
at the end of the table should appear a row summing identifiers (id)
hope it helps. Cheers and GL!
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var entities \EasyCorp\Bundle\EasyAdminBundle\Collection\EntityCollection #}
{# @var paginator \EasyCorp\Bundle\EasyAdminBundle\Orm\EntityPaginator #}
{% extends '@!EasyAdmin/crud/index.html.twig' %}
// !!set the idSumValue to 0
{% set idSumValue = 0 %}
{% block table_body %}
{% for entity in entities %}
{% if entity.isAccessible %}
<tr data-id="{{ entity.primaryKeyValueAsString }}">
{% if has_batch_actions %}
<td class="batch-actions-selector">
<div class="form-check">
<input type="checkbox" class="form-check-input form-batch-checkbox" id="form-batch-checkbox-{{ loop.index0 }}" value="{{ entity.primaryKeyValue }}">
</div>
</td>
{% endif %}
{% for field in entity.fields %}
{% set is_searchable = null == ea.crud.searchFields or field.property in ea.crud.searchFields %}
<td data-column="{{ field.property }}" data-label="{{ field.label|trans|e('html_attr') }}" class="{{ is_searchable ? 'searchable' }} {{ field.property == sort_field_name ? 'sorted' }} text-{{ field.textAlign }} {{ field.cssClass }}" dir="{{ ea.i18n.textDirection }}">
{{ include(field.templatePath, { field: field, entity: entity }, with_context = false) }}
</td>
// !!count idSumValue
{% if field.property == 'id' %}
{% set idSumValue = idSumValue + field.value %}
{% endif %}
{% endfor %}
{% block entity_actions %}
<td class="actions {{ ea.crud.showEntityActionsAsDropdown ? 'actions-as-dropdown' }}">
{% if entity.actions.count > 0 %}
{% if ea.crud.showEntityActionsAsDropdown %}
<div class="dropdown dropdown-actions">
<a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{# don't use FontAwesome 'fa-ellipsis-h' icon here because it doesn't look good #}
{# this icon is 'dots-horizontal' icon from https://heroicons.com/ #}
<svg xmlns="http://www.w3.org/2000/svg" height="21" width="21" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z" />
</svg>
</a>
<div class="dropdown-menu dropdown-menu-right">
{% for action in entity.actions %}
{{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
{% endfor %}
</div>
</div>
{% else %}
{% for action in entity.actions %}
{{ include(action.templatePath, { action: action, entity: entity, isIncludedInDropdown: ea.crud.showEntityActionsAsDropdown }, with_context = false) }}
{% endfor %}
{% endif %}
{% endif %}
</td>
{% endblock entity_actions %}
</tr>
{% endif %}
{% else %}
{% block table_body_empty %}
{% for i in 1..14 %}
<tr class="empty-row">
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
<td><span></span></td>
</tr>
{% if 3 == loop.index %}
<tr class="no-results">
<td colspan="100">
{{ t('datagrid.no_results', ea.i18n.translationParameters, 'EasyAdminBundle')|trans }}
</td>
</tr>
{% endif %}
{% endfor %}
{% endblock table_body_empty %}
{% endfor %}
// !!display the idSumValue
<tr>
<td colspan="100">
{{ idSumValue }}
</td>
</tr>
{% if some_results_are_hidden %}
<tr class="datagrid-row-empty">
<td class="text-center" colspan="100">
<span class="datagrid-row-empty-message"><i class="fa fa-lock mr-1"></i> {{ 'datagrid.hidden_results'|trans({}, 'EasyAdminBundle') }}</span>
</td>
</tr>
{% endif %}
{% endblock table_body %}
from easyadminbundle.
@budzik Thanks for your help :)
I think this feature could be good to implement in EasyAdmin
from easyadminbundle.
Related Issues (20)
- EntityManager::addSearchClause throw exception on Postgresql databases HOT 1
- Dynamic label for custom actions
- Inconsistent behaviour when no entityId is passed to detail page
- Stop using PATCH HOT 18
- Default field for boolean property doesn't load field-boolean.js HOT 4
- Add some join for default query for NEW, EDIT, and DETAIL pages HOT 2
- EasyAdmin Autocomplete clear behaviour
- [Doc] Add an example of custom CRUD action
- Not possible to link a symfony controller HOT 1
- Feature Request: add edit link to Entity grid row name
- Route definitions in read-only file systems
- PercentField ignores "numDecimals" option
- Filters of the previous page shouldn't be passed to the next pages
- Add options to customize `ArrayField` button labels
- Text fields Max Length option is ignored HOT 6
- It doesn't create related records
- Dashboard title tag not set using content_title block HOT 1
- TextEditorType does not render in custom FieldType HOT 1
- How to use same function for two Entity Event ? HOT 1
- CollectionField: Add item and remove buttons do not work in EasyAdmin 4 CRUD update
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyadminbundle.