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

Could not find a way to change the route of the app using the buttons on table #102

Open
lucafs opened this issue Dec 4, 2023 · 1 comment

Comments

@lucafs
Copy link

lucafs commented Dec 4, 2023

      {
        label: "",
        field: "quick",
        width: "5%",
        display: () => {
            # needed a button here to change route here
        },
    },

Tried several different things and could not find a way to do it.. Can you help me?

@linmasahiro
Copy link
Owner

linmasahiro commented Dec 8, 2023

Hi, @lucafs , here is example.

  1. return an element on display function.
{
  label: "",
  field: "quick",
  width: "5%",
  display: (row) => {
     return "<button id='is-rows-el redirect-btn' data-xx='" + row.xx + "'>redirect</button>"
  },
}
  1. add button click event to tableLoadingFinish function
    const tableLoadingFinish = (elements) => {
      table.isLoading = false;
      Array.prototype.forEach.call(elements, function (element) {
        if (element.classList.contains("redirect-btn")) {
          element.addEventListener("click", function () {
            const xx = this.dataset.xx;
            // add your route change code
          });
        }
      });
    };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants