get the title of a column in a cell-event?
get the title of a column in a cell-event?
pballhausen
Posts: 2Questions: 0Answers: 0
Hello DataTables enthusiasts
I'm still a beginner in the use of DataTables and my English is not very good. I have a question, the answer is probably relatively simple:
I want to replicate the functionality of jEditable. So it is based on the class of a cell to open a dialog where you can enter either a text or selecting via radio or checkbox etc..
For this I have devised the following:
[code]
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
$(nRow).attr('id', aData[19]); //User id ist stored in cell 19
return nRow;
},
"fnDrawCallback": function() {
oTable = $('#userTable').dataTable();
$('td').hover( function() {
$(this).addClass('highlighted');
$(this).click( function() {
var cell_classes = this.className;
var cell_value = this.textContent;
var user_id = this.parentNode.id;
var col_index = this.cellIndex;
} );
}, function() {
$('td.highlighted').removeClass('highlighted');
} );
}
[/code]
Additionally, I have but not all columns are displayed. cell index is not equal aTargets of aoColumn.
So I need a way to get the title of a column in a cell-event ..
I'm still a beginner in the use of DataTables and my English is not very good. I have a question, the answer is probably relatively simple:
I want to replicate the functionality of jEditable. So it is based on the class of a cell to open a dialog where you can enter either a text or selecting via radio or checkbox etc..
For this I have devised the following:
[code]
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
$(nRow).attr('id', aData[19]); //User id ist stored in cell 19
return nRow;
},
"fnDrawCallback": function() {
oTable = $('#userTable').dataTable();
$('td').hover( function() {
$(this).addClass('highlighted');
$(this).click( function() {
var cell_classes = this.className;
var cell_value = this.textContent;
var user_id = this.parentNode.id;
var col_index = this.cellIndex;
} );
}, function() {
$('td.highlighted').removeClass('highlighted');
} );
}
[/code]
Additionally, I have but not all columns are displayed. cell index is not equal aTargets of aoColumn.
So I need a way to get the title of a column in a cell-event ..
This discussion has been closed.
Replies
[code]
var col_title = $('td', this.parentNode).parents()[2].children[0].children[0].cells[col_index].textContent;
console.dir(col_title);
[/code]
only problem is, when I redraw the Table, for example because of show another column, the "col_title" will be shown more than one time in the console..
Allan