fnUpdate with fnRender

fnUpdate with fnRender

a2011a2011 Posts: 9Questions: 0Answers: 0
edited January 2012 in General
Hi,

I have searched the forum but I cannot find a soultion to this.

I have a table where one row is images (there are several images but I have simplified the code below) with onclick-events handled by fnRender to call javascrip:viewDetalail(row9).

This works perfect, but after I have done an update using fnUpdate the function call is performed with the parameter undefined/null. Is there anything I can do to fix this?

[code]
// Initialise datatable
var oTable = $('#dt_example').dataTable({
"aaData": data.member_list,
"iDisplayLength": 10,
"aaSorting": [[ 3, "asc" ], [ 2, "asc" ]],
"sDom": 'T<"clear">lfrtip',
"aoColumns": [
{ 'sTitle': 'row0', "sClass": "left" },
{ 'sTitle': 'row1', "sClass": "left" },
{ 'sTitle': 'row2', "sClass": "left" },
{ 'sTitle': 'row3', "sClass": "left" },
{ 'sTitle': 'row4', "sClass": "left" },
{ 'sTitle': 'row5', "sClass": "left" },
{ 'sTitle': 'row6', "sClass": "left" },
{ 'sTitle': 'row7', "sClass": "left" },
{ 'sTitle': 'row8', "sClass": "left" },
{ 'sTitle': 'row9', "sClass": "left", "sWidth" : "120px",
"fnRender": function ( oObj ) {
return '';
}
},
{ 'sTitle': 'Active', "sClass": "left", 'bVisible': false }
]
});

...

// Update a row
oTable.fnUpdate( [em_id, id, ep_firstname, ep_lastname, ep_adress, ep_zip, ep_city, em_year, em_date, em_id, em_active, currRow, 0, 1, 1 );
[/code]

Thanks
//Anders

Replies

  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    Don't use DOM0 events like on click - attach a DOM2 event using jQuery and use the DataTables API to get your data.

    Events demo: http://datatables.net/release-datatables/examples/advanced_init/events_live.html

    Allan
  • a2011a2011 Posts: 9Questions: 0Answers: 0
    Since it is the image I want clickable (and I have several images in the same column) I have added a class to the image and added the function:
    [code]
    $('img.details').click( function() {
    ...
    });
    [/code]

    It works perfectly but the problem is, how do I get the row information there? What I need is an identifier from one of the columns.

    Anders
  • a2011a2011 Posts: 9Questions: 0Answers: 0
    Found it myself after some guessing...

    [code]
    $('td img.details').click( function() {
    var aData = oTable.fnGetData( this.parentNode.parentNode );
    alert(aData[1]);
    });
    [/code]
  • a2011a2011 Posts: 9Questions: 0Answers: 0
    Sorry for spamming... But now when it works I found out that this didn't solva my initial problem. After fnUpdate the images in the updated row don't respond to clicks...

    Any ideas?
This discussion has been closed.