Skip to content

Commit

Permalink
Add grid customisation
Browse files Browse the repository at this point in the history
  • Loading branch information
qsomazzi committed Aug 24, 2015
1 parent d47fa79 commit d83effd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions Resources/doc/reference/action_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -458,4 +458,27 @@ To do:
- targeting submodel fields using dot-separated notation
- advanced filter options (global_search)

Visual configuration
--------------------

You have the possibility to configure your List View to customize the render without overring to whole template.
You can :

- `header_style`: Customize the style of header (width, color, background, align...)
- `header_class`: Customize the class of the header
- `row_align`: Customize the alignment of the rendered inner cells

.. code-block:: php
<?php
public function configureListFields(ListMapper $list)
{
$list
->add('id', null, array('header_style' => 'width: 5%; text-align: center', 'row_align' => 'center'))
->add('name', 'text', array('header_style' => 'width: 35%')
->add('actions', null, array('header_class' => 'customActions', 'row_align' => 'right')
;
}
.. _`issues on GitHub`: https://github.com/sonata-project/SonataAdminBundle/issues/1519
2 changes: 1 addition & 1 deletion Resources/views/CRUD/base_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ file that was distributed with this source code.
{% endif %}

{% spaceless %}
<th class="sonata-ba-list-field-header-{{ field_description.type}} {% if sortable %} sonata-ba-list-field-header-order-{{ sort_by|lower }} {{ sort_active_class }}{% endif %}">
<th class="sonata-ba-list-field-header-{{ field_description.type}} {% if sortable %} sonata-ba-list-field-header-order-{{ sort_by|lower }} {{ sort_active_class }}{% endif %}{% if field_description.options.header_class is defined %} {{ field_description.options.header_class }}{% endif %}"{% if field_description.options.header_style is defined %} style="{{ field_description.options.header_style }}"{% endif %}>
{% if sortable %}<a href="{{ admin.generateUrl('list', sort_parameters) }}">{% endif %}
{{ admin.trans(field_description.label, {}, field_description.translationDomain) }}
{% if sortable %}</a>{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/CRUD/base_list_field.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ file that was distributed with this source code.
#}

<td class="sonata-ba-list-field sonata-ba-list-field-{{ field_description.type }}" objectId="{{ admin.id(object) }}">
<td class="sonata-ba-list-field sonata-ba-list-field-{{ field_description.type }}" objectId="{{ admin.id(object) }}"{% if field_description.options.row_align is defined %} style="text-align:{{ field_description.options.row_align }}"{% endif %}>
{% set route = field_description.options.route.name|default(null) %}
{% set action = route == 'show' ? 'VIEW' : route|upper %}

Expand Down

0 comments on commit d83effd

Please sign in to comment.