Covering OroCommerce, OroCRM, OroPlatform topics, including community updates and company announcements.

Forums OroCRM OroCRM – How do I? Questions Custom Contact List Grid

This topic contains 5 replies, has 2 voices, and was last updated by  zhex900 1 year, 1 month ago.

  • Creator
  • #29347



    I know custom Contact list grid can be saved through the frontend GUI. How do I add a custom grid via code?


Viewing 5 replies - 1 through 5 (of 5 total)
  • Author
  • #29348

    Yurii Muratov

    Hi, @zhex900.

    The predefined data views configures with views_list parameter of your grid config. The value of this parameter is the service that extended from Oro\Bundle\DataGridBundle\Extension\GridViews\AbstractViewsList abstract class.

    This class have abstract function getViewsLis that returns an array of available views.

    For your example, let’s add two new views to the contact grid.
    The definition of the contacts grid available at crm/src/Oro/Bundle/ContactBundle/Resources/config/oro/datagrids.yml. The name of this datagrid is contacts-grid.

    As you can see, this datagrid config already have the views_list parameter with @oro_contact.contacts_view_list value. If you open this service (Oro\Bundle\ContactBundle\Datagrid\ContactsViewList class), you will see, that here we add the Duplicates view.

    So, create new class ContactsExtraViewList somewhere in your bundle and extend it from the ContactsViewList. At this class, let’s rewrite getViewsList method and new views:

    At this example we add two new views. The first one has the filter by firstName field and ‘foo’ value, and the second one has the filter by lastName field with ‘bar’ value.

    After that, you should register your class as service:

    And the last step is to change the views_list parameter for contacts-grid datagrid. To do this, add
    Resources/config/oro/datagrids.yml file at your bundle with content:

    And after the cache reset, you will have new two grid views:



    Thank you! It worked. Another question. How do I filter owner column?


    Yurii Muratov

    Hi, @zhex900.

    The owner field receive the entity id as the value.

    So, your view will be like:

    You can easy test what value format support the filter. In the grid just set some value and see the ajax request data for the grid with this filter. For example, for the owner field the request will be like:




    One more question.
    $followup_view->setColumnsData(['firstName' => ['order' => 1]]);
    What is wrong with this line? I want to control what columns are displayed in the view.



    I have found the answer myself. FirstName should be replaced with first_name.

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

You must be logged in to reply to this topic.

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

Yes No