how to get tag inside cell in datatable

how to get tag inside cell in datatable

kingqgxkingqgx Posts: 5Questions: 0Answers: 0
edited March 2013 in General
Hi,

I generate link in cell through json format from server side, then i want to put click event on link (modify or delete), but i can't get link using $('#myTable tbody tr td a'). code is below:

$(function() {

var oTable = $('#myTable').dataTable({
sScrollY: 200,
"bScrollCollapse": true,
bProcessing: true,
bPaginate: false,
bFilter: false,
bInfo: false,
bSortable: true,
bRetrieve: true,
sAjaxSource: "data.jsp",
aoColumns:[null,
null,
null,
null,
null,
null,
null,
{"bVisible": false}
],
"fnInitComplete": function () {
$('#myTable tbody tr td').on("click", function () {

var aPos = oTable.fnGetPosition( this );

var aData = oTable.fnGetData( aPos[0] );

alert(aData[6]);
} );

}
});

json:

{
"sEcho": 1,
"aaData": [
[
"",
"Gecko",
"Firefox 1.0",
"Win 98+ / OSX.2+",
"1.7",
"A",
"Modify  Delete",
"1"
]
}

I also couldn't get checkbox tag either.

any ideas will be appreciated.

Replies

  • kingqgxkingqgx Posts: 5Questions: 0Answers: 0
    somebody please help, i struggled several days.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    edited March 2013
    Please link to a test case showing the problem. Fundamentally the code above looks okay.

    Allan
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Wait:

    > bRetrieve: true,

    Why is that there?
  • kingqgxkingqgx Posts: 5Questions: 0Answers: 0
    Hi allan,

    thanks for your response. i got rid of 'bRetrieve: true,', still doesn't work.
    i put those code in jsp page, running on Jboss 7, i don't know how to provide test case, can you give me some clue?

    i made mistake, code should be:

    "fnInitComplete": function () {
    $('#myTable tbody tr td a').on("click", function () {

    var aPos = oTable.fnGetPosition( this );

    var aData = oTable.fnGetData( aPos[0] );

    alert(aData[6]);
    } );
    }

    $('#myTable tbody tr td') worked, but when i want to narrow it down to tag, it failed, checkbox tab as well.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    > i don't know how to provide test case, can you give me some clue?

    Yes - give me the Url for the page you are working on. Without a test case I can't help.
  • kingqgxkingqgx Posts: 5Questions: 0Answers: 0
    Hi allan,

    this is just running on my laptop, there is no public IP, i will look for hosting environment.
This discussion has been closed.