OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions Datagrid source based on entity repo?

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

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

  • Creator
    Topic
  • #35940

    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
  • #35941

    Yurii Muratov
    Participant

    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:

    #35942

    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)

    #35943

    Yurii Muratov
    Participant

    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.

    #35944

    Yurii Muratov
    Participant

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

    #35945

    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)

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

Back to top