OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions How do i make a datagridfilter for contexts

This topic contains 4 replies, has 2 voices, and was last updated by  SkaiBoa 2 years, 2 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #36574

    SkaiBoa
    Participant

    Hi,

    I want to make a filter for contexts in the call datagrid, but i dont know how to start.

    Can give me someone a hint ?

    Thanx in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #36575
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    Hi SkaiBoa,

    You can start from this guide https://oroinc.com/orocrm/doc/2.0/cookbook/entities/datagrids

    #36576

    SkaiBoa
    Participant

    Thank you for you reply. But I guess its not so easy.
    I want to extends the call-grid:
    https://github.com/oroinc/OroCRMCallBundle/blob/master/Resources/config/oro/datagrids.yml

    And the context column is added by this extension:
    https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/ActivityBundle/Grid/Extension/ContextsExtension.php

    And for this column i need a filter.

    I guess I need the right event. I found the OrmResultAfter. Is this the right one ?

    #36577
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    Most of the time to add grid filter for existent field you should subscribe to \Oro\Bundle\DataGridBundle\Event\BuildBefore or \Oro\Bundle\DataGridBundle\Event\BuildAfter event, as it’s easier to update grid configuration and optionally map query.

    Modification on next steps should be more complex and not always possible, like filtering should be done before processing results, so I’m not sure you can work with OrmResultAfter.

    Here is example of adding simple filter to datagrid
    https://github.com/oroinc/orocommerce/blob/1.6.1/src/Oro/Bundle/TaxBundle/EventListener/TaxCodeGridListener.php#L138

    And here more complex listener that adds filtering as well
    https://github.com/oroinc/crm/blob/2.6.1/src/Oro/Bundle/ReportCRMBundle/EventListener/Datagrid/OpportunitiesByStatusReportListener.php#L92

    #36578

    SkaiBoa
    Participant

    If anyone need a filter for contexts. This is how I solved the problem:

Viewing 4 replies - 1 through 4 (of 4 total)

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

You will be redirected to [title]. Would you like to continue?

Yes No