ssossossosso

Forums

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

This topic contains 9 replies, has 4 voices, and was last updated by  Pedro Molina 1 month, 4 weeks ago.

  • Creator
    Topic
  • #3786

    klipach
    Participant

    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
    Replies
  • #3832
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    Hello, klipach.

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

    #3835

    Alexandr Smaga
    Participant

    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.

    #3936

    klipach
    Participant

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

    #3937
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    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

    #4255

    klipach
    Participant

    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:

    #4258
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    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.

    #4277

    klipach
    Participant

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

    #4278
    Yevhen Shyshkin
    Yevhen Shyshkin
    Oro Core

    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.

    #34761

    Pedro Molina
    Participant

    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.