Covering OroCRM topics, including community updates and company announcements.  Subscribe

Forums OroPlatform OroPlatform – How do I? Questions How to show ManyToMany in datagrid

This topic contains 1 reply, has 2 voices, and was last updated by 5 months, 3 weeks ago.

  • Creator
  • #62912



    Lets say I have an entity Customer which has a ManyToMany relation to entity Adress. These get fetched via EAGER in Doctrine, so if I dump the entity, it already includes all the addresses.

    How can I show one field of the first address in the datagrid without doing an extra join over the address table? Reason: This gets extremely slow when there are a lot of entries.

    I tried to get the entity in a BuildAfterListener but this gives no results … any hints?

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


    Platform does not have functionality to simple show many to many relation in grid column,
    but has example which may to help implement it for your case.

    Platform has bundle TagBundle. Tag entity has “many to many” relation with other entities and in the TagBundle there is implemented solution to show tags in the grids (For example, account, contact girds).

    May be this example will help you to solve issue.

    How it works.

    TagBundle has Oro\Bundle\TagBundle\Grid\TagsExtension with methods
    – processConfigs modifies grids definition to add the column “tags” in grids.

    – visitResult adds tags data in rows which should be show on the page.

    Loading data for grid is executed in Oro\Bundle\DataGridBundle\Datagrid\Datagrid by method getData.

    $rows = $this->getAcceptedDatasource()->getResults(); returns rows without data about tags.

    Then $this->acceptor->acceptResult($result); applies available extensions for selected rows.
    One of extensions it is TagsExtension which adds information about tags in results.

    This approach will not be gets extremely slow when there are a lot of entries.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.