Forums OroPlatform OroPlatform – Programming Questions Ordinal number on datagrid

This topic contains 1 reply, has 2 voices, and was last updated by  Alexander 2 years, 12 months ago.

  • Creator
  • #28210


    How I can add an ordinal number before every record of a datagrid?
    For instance, this is my datagrid:

    And this is what I would get:

    Thanks a lot!!!

Viewing 1 replies (of 1 total)
  • Author
  • #28211


    Hello @infocurci !

    As I understood, you want some, let’s say, “virtual” grid column which will not exist in schema but will be displayed in a grid and will represent rows numeration ?

    If you want numeration only per page (without taking into account grid’s pagination) and only for particular grid, it can be done on frontend side, so declare new column in yours datagrid.yml

    do not add anything into ‘filters’ and ‘sorters’ for such column, because you will not be able to sort or filter.
    You also can set ‘type: twig’ and define ‘template’ for your numeration column, where you can provide some markup for numbers (if needed). So, this will add new empty column (<td>) into grid.

    At last in view template you will need some JS…

    Not the best solution, i think, but pretty fast one 😉
    But if you want continuous numbering through all grid’s pages – this should be done in backend and will be more complex.

    P.S. Thanks for the good question. It looks like improvement for our grids. Will investigate it.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.