How to click on some columns for link
How to click on some columns for link
JCR1951
Posts: 34Questions: 6Answers: 0
I'm using the simple serverside script.
I like to click on a facebooklogo in a column.
And then go to a facebook account.
In another column I have to click on a youtubelogo.
And then comes a youtube-video.
Is it possiible?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Absolutely, use https://datatables.net/reference/option/columns.render . In addition, you can also set https://datatables.net/reference/option/columns.data to null.
Although i would put all of these icons in a single "Actions" column.
[code]
$(document).ready(function() {
[/code]
Thanks for the fast reply.
I tried this code.
But the data still undefined.
Even if I give the data a "http://www.facebook.com".
And now with targets I cant call another colomn.
The "data" option is expecting a "download_link" variable in the json object being added to the row. So in this instance, what are you expecting the data value to be in the render function?
The hrefs (http:www.facebook.com/...) are coming from the database.
So I was thinking that info was enough...
Sorry for my bad English...
Looking at this example, https://datatables.net/examples/server_side/object_data.html , notice how the Ajax data is formatted. So each columnDefs.data corresponds to a variable within returned Ajax data. So make sure the variable you assigned the href link to is "download_link".
I did change it...at the serverside and the clientside.
Please help me to find the solution now for the different column clicks.
I'm still a beginner in these things.
server_processing.php
[code]
$table = 'markers';
$primaryKey = 'id';
$columns = array(
);
$sql_details = array(
'user' => 'xxxxxxxxx',
'pass' => 'xxxxxxxxxxxxxxxx',
'db' => 'xxxxxxxxxxx',
'host' => 'xxxxxxx'
);
require( 'ssp.class.php' );
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
[/code]
simple.html
[code]
$(document).ready(function() {
} );
[/code]
Here is a basic example of what I am trying to explain http://live.datatables.net/darujobi/1/edit?js,output
I copied your script for testing.
There is an error.
simple.html:92 Uncaught TypeError: data.each is not a function
Thanks for your time!
haha yeah i figured as much. I use http://sugarjs.com/ which is an extension of Jquery library. You can either include that or change the .each() to a normal js loop.
This works for me...
Maybe you can help me to do this in a hidden column.
And then click on the facebook logo (image) in the row to activate the hidden value in that row.
[code]
$('#example tbody').on( 'click', 'td', function () {
var url = $(this).html().trim();
var m = url.search("http");
if (m > -1)
{
window.open(url);
}
[/code]
see also:
http://www.pctraverse.nl/DataTables-1.10.11/examples/server_side/simple.html
Let me see if I understand you, you want to click on the Facebook logo (which is in a visible column), and that in turn fires a link in a hidden column?
Also, your link example is firing way too many alerts. Seems like alerts are firing for each column in row.
The new code gives all the values of the td's. Except the hidden fields.
And it gives loops more and more, whenever I click a row.
I started a new question.... There is more code..
https://datatables.net/forums/discussion/35210/jquery-doesnt-take-hidden-td