How to get "field-name" of clicked column?
How to get "field-name" of clicked column?
[Deleted User]
Posts: 0Questions: 1Answers: 0
I initialize my table columns like this: { data: 'field1' }, {data: 'field2' }, ...
. How can I get the field name (field1
, field2
) of the cell that is clicked? Here is what I have so far...
$('#phoneTable').on('click', 'tbody td:not(:first-child)',
function (e) {
var idx = phoneTable.cell(this).index().column;
console.log('clicked col # ' + idx);
phoneTableEditor.inline(this);
});
This discussion has been closed.
Answers
This seems like such a simple request. Is there no way to do this? I guess I can just save my own array of fields and then use the index that I found. However, what happens if the user re-orders the columns? The cell().index().column won't work there.
Hi,
There currently isn't a public API for doing this I'm afraid. In the "private" settings object you can read
settings.aoColumns[ idx ].mData
which would give you this information.I totally agree that this is feature that is lacking and it is something that I will look into adding to the API soon as I stumbled across this myself yesterday as well.
Allan
Committed here. Will be in 1.10.3.
Allan