Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Pass parameter to DataGrid

    Modules
    2
    5
    781
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      Luke last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • P
        prateek-webkul last edited by

        Hi @Luke,

        You can access the parameters from route in your datagrid.

        Thanks

        1 Reply Last reply Reply Quote 0
        • L
          Luke last edited by

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

          1 Reply Last reply Reply Quote 0
          • P
            prateek-webkul last edited by

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

            L 1 Reply Last reply Reply Quote 0
            • L
              Luke @prateek-webkul last edited by

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post