How to show the each contents of the cell in dialog box when mouse click is done?

How to show the each contents of the cell in dialog box when mouse click is done?

sahosaho Posts: 16Questions: 11Answers: 0
edited September 2016 in Free community support

As am the novice programmer using DataTables concept .

I would like to show the cell cell contents of the table in popup(dialog box) whenever mouse is clicked inside the cell?

i attached you the sample code which i have tried.

`
Code:

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">


</head>

<

table border="1" align="right" id="example1" class="display1" width="100%">

$(document).ready(function() { $('#example tbody').click(function() { alert("test"); }); });
a b c d e
1 2 3 4 5
3 6 9 7 12

</html>

`

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin

    Using DataTables 1.10's API (since 1.9.4 is no longer supported) you would simply do:

    $('#example').on( 'click', 'tbody td', function () {
      alert( table.cell( this ).data() );
    } );
    

    The cell().data() is the method used.

    There are a lot of good jQuery event tutorials on the web if you are just starting out with them.

    Allan

  • sahosaho Posts: 16Questions: 11Answers: 0

    Did the 1.10.12 version will support for alert

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin

    The DataTables version is irrelevant for alert that is a global Javascript method.

  • sahosaho Posts: 16Questions: 11Answers: 0

    But in general DataTables example i found alert.

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin
    Answer ✓

    You'll also find jQuery calls, and DOM manipulation. That doesn't mean that DataTables provides all of them.

    This is the MDN documentation for alert().

This discussion has been closed.