OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions How to add columns to contact datagrid and change an order?

This topic contains 9 replies, has 4 voices, and was last updated by  Pedro Molina 2 years, 8 months ago.

The forum will run in the read-only mode starting from March 1. Please head to StackOverflow for support.

  • Creator
  • #33334


    I have clean installation of Orocrm with some user data. I created a ContactBundle in src directory do adjust templates to my needs. When i put datagrid.yml into my bundle i get error: “Datagrid source “Array” does not exist”. How can i add columns and change the order?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Author
  • #33335

    Hello, klipach.

    Look’s like you set incorrect datagrid source type parameter. Could you, please, put your datagrid configuration here?


    Alexandr Smaga

    Hello @klipach

    Please take a look to our standalone package, there is an example how bundle could be extended, how datagrid could be modified. And also take a look to event listener that changes columns order.



    Is there some where an example how can i change columns order and add columns in Customers grid (or any other grid)?


    Basic solution for that is to create listener on buildBefore that will update datagrid configuration – there you can customize ordering and add other columns.
    Listener example: https://github.com/orocrm/crm/blob/master/src/OroCRM/Bundle/CallBundle/EventListener/Datagrid/CallListener.php

    Advanced way is to extend datagrid, update it and reuse in your bundle.
    Configuration example: https://github.com/orocrm/crm/blob/master/src/OroCRM/Bundle/ContactBundle/Resources/config/datagrid.yml#L345



    Thank you for a reply, as i understand if i want to modify contacts-grid i can do it only via listener?
    I need to show middleName, address and city.

    I found a way how to remove columns from datagrid but can’t add new one. Can you give me a hint how to do it? Here is my Listener:


    You should add column to query builder select and add columns configuration with sorters and filters.

    I’d recommend you to do it in datagrid.yml in ContactBundle first just to find out and test how it should look like, and then do exactly the same thing from listener.

    Here is example if such listener https://github.com/orocrm/platform/blob/master/src/Oro/Bundle/WorkflowBundle/Datagrid/WorkflowStepColumnListener.php#L131 – don’t look at business logic, just try to find how configuration is modified.



    Thank you, did it. And how i can change the order of columns in the listener?


    You simply have to put columns in correct order – f.e. you can use array_splice to inject your column in the middle of configuration. Simple example (without array_splice) can be found here https://github.com/orocrm/OroCRMMagentoContactUsBundle/blob/master/Datagrid/ContactRequestDatagridHelper.php.


    Pedro Molina

    Hi, how did you manage to add columns? i still dont get to do that with this method. I have this code to add some columns, but cant add certain columns to case grid and im unable to apply a method in the “field” value, for example:
    I need to show the “fullName” of related contact column of the case datagrid, that is a concatenation of first name and last name. Here is my code, if anyone can help me:

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

You must be logged in to reply to this topic.

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

Yes No