APYDataGridBundle icon indicating copy to clipboard operation
APYDataGridBundle copied to clipboard

actions first

Open grekpg opened this issue 7 years ago • 15 comments

Is possible to change actions to to first td ?

grekpg avatar Mar 29 '17 10:03 grekpg

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
};

DonCallisto avatar Mar 29 '17 12:03 DonCallisto

@grekpg it works?

DonCallisto avatar Mar 31 '17 08:03 DonCallisto

I did this without the manipulate render, you can override the template and put the actions columns in the first position.

QuentinCurtet avatar Apr 06 '17 12:04 QuentinCurtet

@quentincurtet can I close this?

DonCallisto avatar Apr 16 '17 09:04 DonCallisto

for my not work ... can someone paste example modification to show actions first?

grekpg avatar May 24 '17 10:05 grekpg

@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?

DonCallisto avatar May 24 '17 10:05 DonCallisto

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 %}

grekpg avatar May 24 '17 10:05 grekpg

You should use {{ grid_actions(grid) }} in order to render it AFAIK

DonCallisto avatar May 24 '17 10:05 DonCallisto

but grid_actions is mass actions, i ask how to move to first column row actions

grekpg avatar May 24 '17 11:05 grekpg

@grekpg sorry so, I don't understood and still don't understand the question :\

DonCallisto avatar May 24 '17 12:05 DonCallisto

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.

QuentinCurtet avatar May 24 '17 12:05 QuentinCurtet

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

AlessandroMinoccheri avatar May 24 '17 14:05 AlessandroMinoccheri

@grekpg do you still need the issue open or did you successfully tackle this?

DonCallisto avatar Jun 29 '17 08:06 DonCallisto

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 avatar Jun 29 '17 08:06 grekpg

@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

DonCallisto avatar Jun 29 '17 09:06 DonCallisto