Insert a link into a button
Insert a link into a button
tsurubaso
Posts: 32Questions: 8Answers: 0
in DataTables
Link to test case:
https://gist.github.com/083976ef44d73d29f799ea3c7d198529
Debugger code (debug.datatables.net):
The part of the code in question.
function drawTwitterSearchResultsTable(datatransformed) {
$(document).ready(function () {
$('#searchTable').DataTable({
data: datatransformed,
columns: [
{ title: "Word(s)" },
{ title: "Text" },
{ 'data': null, title: 'Link', "render": function (e, dt, button, config ) { return '<div class="btn-group"> <button type="button" class="btn btn-light" ><a href="'+$(this)+'" target="_blank">Link</Link</a></button></div>' } },
]
});
});
};
xxxx
//Twitter related functions
window.electron.ipcRendererWithFunction('TwitterData', function (event, result) {
console.log(result);
document.getElementById('word').innerText = wordToSearch;
document.getElementById('word').classList.remove("forJapanese");
document.getElementById('searchTable').style.display = '';
datatransformed = [];
for (var i = 0; i < result[0].length; i++) {
datatransformed.push([wordToSearch, result[0][i], result[1][i]]);
}
console.log(datatransformed);
if ($.fn.DataTable.isDataTable('#searchTable')) {
$('#searchTable').DataTable().clear().destroy();
$('#searchTable').empty();
}
drawTwitterSearchResultsTable(datatransformed);
result = undefined;
});
Error messages shown:
No error
Description of problem:
I need to insert for each row the link data.
I am completely new to Jquery, and quite new to Datatable.
I am learning in express Jquery.
I need to insert the Link in the Href for each row.
Thanks for your help
This discussion has been closed.
Answers
It looks like you're doing the right thing, using
columns.render
. What's the problem with what you've got? You haven't said what the issue is. Also, as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.Cheers,
Colin
Hello Colin, and thanks to answer.
I found the solution!!
It is may be not clean at all but it works!
Here is the Electron Fiddle (You have to enter your keys for it to work).
https://gist.github.com/083976ef44d73d29f799ea3c7d198529
and here is the part of the code in direct relation with my (solved) problem.
Thanks again Colin.