Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript Grid Actions #34

Open
schmengler opened this issue Feb 7, 2021 · 2 comments
Open

JavaScript Grid Actions #34

schmengler opened this issue Feb 7, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@schmengler
Copy link
Contributor

A feature I'd like to see: allow something like "onclick" instead of "url" in grid actions. This allows AJAX requests, popups and other actions that do not require navigating to a new page

@Vinai
Copy link
Collaborator

Vinai commented Feb 7, 2021

What should the attribute value be... a JavaScript expression, for example a function name?
I'm wondering how that could be kept extendable... maybe if it is a JSON object with keys and the values are the callbacks/expressions?
E.g.

<action id="example" onclick="{example: openPopup}"/>

In this example, would openPopup be a global function on window?
And another question is how could the action rowId value be used in the expression? Maybe with a special $idParam pseudo-variable that get's swapped out with a string_replace?

On the other hand, maybe it's better to keep things simpler and just allow for function names and they are called with the row id param.

Another idea I had was to allow the configuration of events that are dispatched when the trigger happens. Then the subscribers could be anywhere.

<action id="example">
    <event on="onclick"/>
</action>

This would trigger an event with the name hyva_grid_[grid-name]_example_onclick.
I like this approach because it makes it easy to extend and pass multiple arguments.

@schmengler
Copy link
Contributor Author

schmengler commented Feb 8, 2021

That's a good thing to discuss openly, I don't have a strong opinion on how it should work.

But the event suggestion sounds elegant to me and matches the Hyvä spirit. How would you add arguments though? Nevermind, I'm looking at #35 now :)

@Vinai Vinai added the enhancement New feature or request label Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants