ssossossosso

Forums

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

This topic contains 5 replies, has 2 voices, and was last updated by  jakabadambalazs 2 years, 3 months ago.

  • Creator
    Topic
  • #9245

    jakabadambalazs
    Participant

    Hi,

    I have an entity for which I have created a dashboard widget with a datagrid inside.
    In this datagrid I’d like to implement a predefined sorting order which is quite complex(based on three properties) and I am unable to do it with datagrid.

    Is it possible to use an entityRepo method to do all the logic returning a QueryBuilder object to the datagrid?

    thanks
    a\


    oro/platform(1.6.2) + oro/doctrine-extensions(1.0.7) + symfony/symfony(v2.3.27)

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

    Yurii Muratov
    Oro Core

    Hi, jakabadambalazs.

    As for me, in this case you can do this in grid configuration yml file.

    Let’s look in widget gatagrid configuration https://github.com/orocrm/crm/blob/master/src/OroCRM/Bundle/ContactBundle/Resources/config/datagrid.yml#L2

    Here we have grouping by 4 fields and order by one field. If You need order by many fields, You can change config to:

    #9256

    jakabadambalazs
    Participant

    Hi @yurio,

    thanks I tried “order_by”, “order” .. and probably some other stuff but I didn’t think about “OrderBy”.

    Probably this will do – my use case is that I want to order Tasks by mixing two fields: priority (1-3) and Due Date to give me an indicator of “urgency” – the thing is that I cannot order by columns as you are showing above because ordering is sequential and it would not give me the same result.

    But probably I need to craft a calculated field resulting in a numeric “urgency” indicator first and then do ordering by that.

    But I am still interested – is there a way to create a “dynamic” datagrid from php without using yml?


    oro/platform(1.6.2) + oro/doctrine-extensions(1.0.7) + symfony/symfony(v2.3.27)

    #9258

    Yurii Muratov
    Oro Core

    Hi, @jakabadambalazs.

    In example above, contactName is the ‘calculated’ field. Yes, You should create calculated field and than sort by this field.

    You can use repository method for the datagrid. In this case, your configuration of datagrid should be like:

    Your repository method should return Query Builder.

    #9259

    Yurii Muratov
    Oro Core

    If You should change grid config on-the-fly, You can write datagrid listener for your grid and change any parameter of your grid.

    #9262

    jakabadambalazs
    Participant

    Sweet! Thanks! This is what I was looking for!


    oro/platform(1.6.2) + oro/doctrine-extensions(1.0.7) + symfony/symfony(v2.3.27)

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

You must be logged in to reply to this topic.