APYDataGridBundle
APYDataGridBundle copied to clipboard
actions first
Is possible to change actions to to first td ?
You can manipulate actions with addManipulateRender
(or manipulateRender
that is deprecated and will be removed): base on row values you can return or not an action and if it is not returned, it will be not displayed.
$action = new RowAction(...);
$action->addManipulateRender(function ($action, $row) {
// some logic here
};
@grekpg it works?
I did this without the manipulate render, you can override the template and put the actions columns in the first position.
@quentincurtet can I close this?
for my not work ... can someone paste example modification to show actions first?
@grekpg sorry, I must have misinterpreted your question: if you need to have actions in first td, just override the template. Are you using symfony?
yes, im look on template but what change , this block ?
{% block grid_rows %}
{% for row in grid.rows %}
{% set last_row = loop.last %}
{% spaceless %}
{% set gridColumns %}
{% for column in grid.columns %}
{% if column.visible(grid.isReadyForExport) %}
<td
class="
grid-column-{{ column.renderBlockId }}
{{ column.class|default("") }}
{% if column.align != 'left'%}
align-{{ column.align }}{% endif %}{% if loop.last %}
last-column{% endif %}{% if last_row %}
last-row{% endif %}
">{{ grid_cell(column, row, grid)|raw }}</td>
{% endif %}
{% endfor %}
{% endset %}
<tr id="row{{row.getPrimaryFieldValue}}" {% if row.color != '' %} style="background-color:{{ row.color }};"{% endif %} class="grid-row-cells {{ cycle(['odd', 'even'], loop.index) }} {{ row.class|default("") }}">
{{ gridColumns }}
{% endspaceless %}
</tr>
{% else %}
{{ grid_no_result(grid) }}
{% endfor %}
{% endblock grid_rows %}
You should use {{ grid_actions(grid) }}
in order to render it AFAIK
but grid_actions is mass actions, i ask how to move to first column row actions
@grekpg sorry so, I don't understood and still don't understand the question :\
I override the blocks.html.twig :
{% block grid_filters %}
<tr class="grid-row-filters" style="display:none;">
{% for column in grid.columns %}
{% if column.type == 'actions' %}
<th class="{% if column.class %}{{ column.class }}{% endif %}{% if loop.last %} last-column{% endif %}"{% if(column.size > -1) %} style="width:{{ column.size }}px;"{% endif %}></th>
{% endif %}
{% endfor %}
{% for column in grid.columns %}
{% if column.type != 'actions' %}
{% if column.visible(grid.isReadyForExport) %}
<th class="{% if column.class %}{{ column.class }}{% endif %}{% if loop.last %} last-column{% endif %}"{% if(column.size > -1) %} style="width:{{ column.size }}px;"{% endif %} onclick="event.preventDefault()">{% if column.filterable %}{{ grid_filter(column, grid)|raw }}{% endif %}</th>
{% endif %}
{% endif %}
{% endfor %}
</tr>
{% endblock grid_filters %}
I did the same in the grid_rows block.
Override the blocks I'ts a solution but I think that you could calling the function setColumnsOrder
by passing it an array with the columns id in order @grekpg
@grekpg do you still need the issue open or did you successfully tackle this?
No i dont have it, setColumnsOrder - actions column have name ? or its injected later. Mybe someone can paste full template example with actions row in first position?
@grekpg yes, actions column do have an id so you need to find what it is (as we can't see code) and use setColumnsOrder
accordingly