Forums OroCRM How to Render 2nd datagrid based on click event of row on 1st datagrid in Twig

This topic contains 5 replies, has 2 voices, and was last updated by  shreyas 1 year, 4 months ago.

  • Creator
  • #27336


    Hi Team,

    I have a requirement wherein i need to display a second datagrid(leadfilterby-account) wherein it display lead details for a specific account number that would be obtained from 1st datagrid (accounts-grid2) row click in same twig with no page reload.
    Here for each Account row by its account Id field i am able to get the Account Id. So once a Row is clicked i am able to get its id & calling a controller with AccountId which would be given as parameter to a Query which gives me response . The response i am obtaining is correct & i am able to get back in Twig. But i need The Response to be as a Lead Datagrid(leadfilterby-account) which could get displayed & needs changed Lead Data each time a row is clicked from above Datagrid(accounts-grid2) without any reload of page.

    Please find the below Datagrid code for accounts-grid2 & leadfilterby-account given below:

    Here in Account grid(accounts-grid2) i am using an hidden field(accId) to get account Id to be used in Click Event to get Id through Jquery.

    Please find code for Controller (Loc: ProjDir\src\Custom\Bundle\OroBundle\Controller\CustomRoleController.php) function given below to render these datagrids:

    please find the twig files below for Account grid & Lead Grid:


    Here in the above twig file i need to show the leadgrid.html.twig’s Datagrid i.e(leadfilterby-account) with a dynamic parameter to it as accountId that gets generated each time on Account grid row click. So once clicked only the
    Datagrid2(leadfilterby-account) has to be refreshed with the new values corresponding to account clicked without loading the page.This is where i am stuck on how to get.


    I could use the response currently i am getting to build a table similar to that done in a Datagrid & use css for UI . But the issue is i need it to be a Datagrid itself since it provides most of function like sorting,filtering,deleting,pagination , editing & viewing . So Please need help on how to go above with this.

    i looked at some of references given below but could not get from where to start & no clear understanding on what to do. In some places – actions are used & some of them with mediator in js files which i am not aware about at all & dont even know whether these would be used in getting solution for the requirement.


    Please find below the Account Grid View(accounts-grid2) where i am able to get JSON response for Lead Values shown in FIrebug which are with Account Id -31:

    Account Grid with Lead JSON Response

    Please find below another datagrid-(leadfilterby-account) view screenshot that has a hardcoded value for account Id passed from controller(In example AccId is 24) from function leadbasedonacccheckAction() shown in above Controller code:

    Lead Grid View for AccountId 24

    Kindly need help if any resource or any suggestions on how to go about with to solve this issue .

    Thanks & Regards,
    Shreyas S

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

    Mike Kudelya


    I have made similar case between users and contact grid.

    Extend data grid bundle:


    Override original widget.html.twig, src/Custom/Bundle/DataGridBundle/Resources/views/Grid/widget/widget.html.twig

    You can extend OroCRMContactBundle and override

    Here is important part of view.html.twig

    Now user-grid-widget is listening row clicks, after which it set two parameters. Necessary to add the listener which get this parameters and build datagrid




    Hi Mike,

    Thanks a lot for providing me with the solution.I will get back if any issues.

    Thanks & Regards,
    Shreyas S



    Hi Mike,

    It worked. Thanks a lot for the solution.

    Here i am facing bit issue in routing.yml (In Oro\Bundle\DataGridBundle\Resources\config\oro\routing.yml)where in oro_datagrid_bundle‘s resource parameter value has been changed to Complete path of project folder.If it is kept unchanged to default path i.e @OroDataGridBundle/Controller It throws an exception in browser.

    Please find the below steps followed as per your solution.Let me know if i missed anything:

    Extended Datagrid bundle into a new bundle (CustomSrcDataGridBundle) under location : Proj_Dir\src\Custom\Bundle\SrcDataGridBundle\CustomSrcDataGridBundle.php same as the one you have done for CustomDataGridBundle.php & also the widget view page same as widget.html.twig shown by you to file under loc:Proj_Dir\src\Custom\Bundle\SrcDataGridBundle\Resources\views\Grid\widget\widget.html.twig.

    As per our requirement Lead Records(Datagrid 1) would be shown for particular Account in Account view page & now when a lead is clicked the respective service history (Datagrid 2) specific to that lead has to shown up in Account’s View Page .Please find code snippets given below:
    In CustomAccountBundle View Page under loc:Proj_Dir\src\Custom\Bundle\AccountBundle\Resources\views\Account\view.html.twig

    Here in above code account-lead-grid-internal Datagrid (Datagrid 1) contains list of all leads for the Account viewed.
    Now on click of any Lead displayed through account-lead-grid-internal the event listener displays service history records from service-history-grid3 (Datagrid 2) Datagrid.
    Event Listener for Lead is written in Loc: Proj_Dir\src\Custom\Bundle\OroBundle\EventListener\LeadGridListener.php

    Here leadid is sent to service-history-grid3 Datagrid to display results only to that lead.

    Please find the services.yml file given below Loc in: Proj_Dir\src\Custom\Bundle\SrcDataGridBundle\Resources\config\services.yml

    Please find code snippet for service-history-grid3 given below:

    With all these above steps if i try loading Application . i get exception in browser as follows:

    Please find error screenshot below:
    Error in Datagrid Configuration

    Now when i tried changing Routing.yml present in Location:Proj_Dir\vendor\oro\platform\src\Oro\Bundle\DataGridBundle\Resources\config\oro\routing.yml to given below code, It works:

    Now here Issue faced is that In the code above we have hardcoded the project Directory to : ‘/websites/Proj_Dir/crm-application/vendor/oro/platform/src/Oro/Bundle/DataGridBundle/Controller’ which is not a Good practise as the project directory changes often & each time to remember & change this is difficult process.

    So with the Resource value set to Hardcoded Project Directory Path , the code is working absolutely fine.

    I also tried extending the Datagrid Bundle to a Custom Bundle & Overriding the routing.yml but it also gave same exception.

    Please need help if any suggestions on how to solve this issue.

    Thanks & Regards,
    Shreyas S


    Mike Kudelya

    I think the reason why you got this error is that symfony can’t find oro_datagrid_index route because you have overridden the GridController.php and forgot extend it from base controller.

    For example i have created custom bundle with parent OroDataGridBundle and have created Custom\Bundle\DataGridBundle\Controller\GridController.php

    delete function getAction and got the same error.



    Hi Mike,

    You were Right.The Datagrid Bundle was not extended properly as GridController was missed in Custom Bundle.
    Now it is working absolutely fine.Thanks so much.

    Thanks & Regards,
    Shreyas S

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

You must be logged in to reply to this topic.