Custom dropdown button in ModelTable #1920
Replies: 2 comments
-
I need to do this in one of my projects but I can't implement it. |
Beta Was this translation helpful? Give feedback.
-
Hello everyone, I’ve found a very satisfactory solution. For this solution, I’m using PowerGrid Livewire version 6.3.1. Please note that you may need to make adjustments if you're using a different version. Step 1: Publish the views
Step 2: Modify the header view In: myproject/resources/views/vendor/livewirepowergrid/components/frameworks/tailwind/header.blade.php Inside the div with the class flex flex-row items-center text-sm flex-wrap, I added the following:
Here’s the full modified section:
Step 3: Create the dropdown menu partial In: myproject/resources/views/components/datatable/dropdown-menu.blade.php I inserted the complete code for the dropdown menu:
Step 4: Handle selected rows in the component Note that Option 1 is able to capture the rows selected via checkbox. This means you can perform actions on the selected records. To support this, ensure your Livewire component (ModelTable) contains the following method:
Let me know if you'd like a downloadable version or want help turning this into a reusable component! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I'm facing a very specific issue regarding the frontend layout of the buttons in the PowerGrid header, and I would appreciate any assistance you can provide.
In my project, I need to add a button with a dropdown menu inside the ModelTable.
This is necessary because there are too many action options, and creating a separate button for each one would not be visually practical.
To achieve this, I used:
->includeViewOnTop("components.datatable.model-header")
However, this approach causes the custom button to overlap the native PowerGrid buttons (such as "Export CSV" and "Show/Hide Columns").
Additionally, when the dropdown menu is opened, it pushes the existing buttons downward, disrupting the layout.
Currently, my best workaround has been to manually adjust the CSS to position the button correctly.
However, when the sidebar is open, the positioning breaks again.
While I could continue tweaking the CSS, I would prefer to know if there is a more appropriate or recommended way to handle this.
Setting the button with position: relative leads to so many layout issues that it doesn't seem worthwhile to pursue that path.
Below is the code for my model-header.blade file and a screenshot showing the current result:
Beta Was this translation helpful? Give feedback.
All reactions