Pass parameter to DataGrid



  • Hi,

    I made a custom package where the user can view a series of items based on the product that they choose in the Catalog Page.

    I managed to pass the product id via route but i cannot pass the product id to the datagrid page.
    Right now the datagrid display all the products available in my system even though in my route, it's clear i only pick one product only.

    As you can see here, this is my route with the product id.
    508ab1ed-074a-457b-a513-9d5fd58089cf-image.png

    This is my custom controller to view the page where the datagrid inject.
    2b7c22dd-405a-405c-a23d-dd6984c50baa-image.png

    This is where the datagrid inject the data to the view.
    5c339e83-ae23-4e66-ad82-208e40b98145-image.png

    This is my datagrid code. I tried calling product id, but undefined error came out.
    a8ca2e35-5f6c-453f-99f2-df94d2ce0ff5-image.png

    As you can see here, there's another product in the datagrid. I cannot find a solution to pass the product id to the datagrid.
    22025563-fe41-4460-b206-3f24635d40a9-image.png

    I hope someone can show me the solution on how to pass id to the datagrid.



  • Hi @Luke,

    You can access the parameters from route in your datagrid.

    Thanks



  • @prateek-webkul so just put my $id in ny datagrid code and it will work?



  • @Luke use request()->route('product_id') to access product_id in your data grid passed from controller to view.



  • @prateek-webkul okay, thanks so much!!!!


Log in to reply