Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!

Jack990 priority asked 2 years ago


Hello

sorry for a dumb question, but I cant figure it out, and I am not a js expert.

I have a datatable and want to have the row be like a url link, so when clicking on row it takes users to a url made from the content of the first column. Is that possible?

best, h


Dae free answered 2 years ago


is much easier to use a button to do the action you want. I know is not the same behavior but much easier to do it. You can add a button/image/icon and add an onclick='....' event.

if you are doing it on HTML </p><br><br>

<td><i class="fas fa-times" onclick="window.open('https://www.url.com','_blank');"></i></td>

Also you can add here ID or diferent URL for each row.

Hope this helped you.


Dae free answered 2 years ago


In datatable documentation you have "Clickable rows". That is what you are looking for.

In the part of the code you see below you can do what you want: window.open(); document.location.href... etc. But at the end is not a easy and fast as you could expect.

table.addEventListener('rowClick.mdb.datatable', (e) => { const { index } = e; const { message, title, from } = messages[index];

modalHeader.innerText = title; modalBody.innerHTML = <h6 class="mb-4">From: <strong>${from}</strong></h6> <p>${message}</p> ;

modalInstance.show(); });


Jack990 priority commented 2 years ago

Thank you so much, yes looks quite easy, will try!

thanks a lot. jack



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 5.0.0
  • Device: mac
  • Browser: chrome
  • OS: macos
  • Provided sample code: No
  • Provided link: No