Topic: datatables
Jack990 free 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 free commented 2 years ago
Thank you so much, yes looks quite easy, will try!
thanks a lot. jack
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB Standard
- MDB Version: MDB5 5.0.0
- Device: mac
- Browser: chrome
- OS: macos
- Provided sample code: No
- Provided link: No