add new row and set img click event on one column of newly created row
add new row and set img click event on one column of newly created row
manoharsolanki123
Posts: 8Questions: 0Answers: 0
Hi Allan,
I need to add a new row to a datatable which I have achieved using fnAddData()
Now on this row I have a image which on clicked supposed to opens a dialog box.
I have this click function working for existing rows, but when a new row is added this click event is not working.
Not sure but I suppose its a post initialisation event, so I saw the tooltip eg on your site.
But my confusion is that what do I use $( oTable.fnGetNodes() ).XXXXX here
Thanks in advance
code is below:
[code]
$(document).ready(function() {
oTable = $('#addModifySuppTbl').dataTable();
$('#add').click( function() {
$('#addModifySuppTbl').dataTable().fnAddData( [
"",
"",
"",
"",
"",
""
],true );
giCount++;
});
$('td img', oTable.fnGetNodes() ).each( function () {
$(this).click( function () {
var rowIndex = this.parentNode.parentNode.rowIndex;
/* Get the position of the current data from the node */
var aPos = $('#addModifySuppTbl').dataTable().fnGetPosition( this );
//Opens a dialog for that row
$('#searchDialog').data("rowIndex",rowIndex).dialog('open');
} );
} );
});
[/code]
regards,
Manohar
I need to add a new row to a datatable which I have achieved using fnAddData()
Now on this row I have a image which on clicked supposed to opens a dialog box.
I have this click function working for existing rows, but when a new row is added this click event is not working.
Not sure but I suppose its a post initialisation event, so I saw the tooltip eg on your site.
But my confusion is that what do I use $( oTable.fnGetNodes() ).XXXXX here
Thanks in advance
code is below:
[code]
$(document).ready(function() {
oTable = $('#addModifySuppTbl').dataTable();
$('#add').click( function() {
$('#addModifySuppTbl').dataTable().fnAddData( [
"",
"",
"",
"",
"",
""
],true );
giCount++;
});
$('td img', oTable.fnGetNodes() ).each( function () {
$(this).click( function () {
var rowIndex = this.parentNode.parentNode.rowIndex;
/* Get the position of the current data from the node */
var aPos = $('#addModifySuppTbl').dataTable().fnGetPosition( this );
//Opens a dialog for that row
$('#searchDialog').data("rowIndex",rowIndex).dialog('open');
} );
} );
});
[/code]
regards,
Manohar
This discussion has been closed.
Replies
Allan
It does worked.
Regards,
Manohar
It solves me the same question
Ray