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.

    This is my custom controller to view the page where the datagrid inject.

    This is where the datagrid inject the data to the view.

    This is my datagrid code. I tried calling product id, but undefined error came out.

    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.

    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.


  • @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