Find the index of a column
Find the index of a column
Hi guys,
I need to find the index of a column by name. I can get that, but what is messing me up is that a couple of columns on the LEFT side of the column I need can be set to visible or not visible. This changes the index that I need to use from 8 to 6 if both go from visible to hidden.
var columns = table.settings().init().columns;
table.columns().every(function(index) {
if(columns[index].name) {
console.log('Column ' + index + ' name is: ' + columns[index].name);
}
})
This shows me the column names, but I can't figure out how I can find if the column is visible or not... Note that not all the columns have names, but I'm not sure if that matters.
Essentially I need to know the column index of column with name "po_amt" so I can update the value in the column with something like:
jQuery("td:eq(6)", row).text(amtPO);
Any ideas most appreciated!
Best regards,
Answers
You can use
column().visible()
to determine if a column is visible - that one method is a setter and a getter. If that doesn't help, could you generate a test case, please, to help understand the issue. Information on how to create a test case is available here.Cheers,
Colin
Kevin, @kthorngren , helped me with a similar request with this plugin:
you can see it in use here:
http://live.datatables.net/rutatuka/1/edit
the full thread of my post is here:
https://datatables.net/forums/discussion/71484/separate-excel-sheet-for-each-row-grouping#latest
hope this helps
Hi guys,
Thank you so much. I was trying the visible, but I think I was trying it on the columns() object not column() - not the same thing!<g>
I will test this out and let you know!
Best regards,