More efficient and CLEAR way to express
More efficient and CLEAR way to express
menashe
Posts: 200Questions: 45Answers: 2
in DataTables 2
I have the following statement which works:
low_price_index = packagingTable.columns('lowest-price:name')[0][0] + 1 - (packagingTable.column('manufacturer:name').visible() != true ? 5 : 0);
In short, I am computing the Index of the lowest-price column. I also know that if the manufacturer column is hidden, I have also hidden four other columns, for a total of five.
I use the returned Index to color/highlight the column in the table.
Is there a cleaner way to code this? (Any functions that I may not be aware of that account for hidden columns?)
This question has an accepted answers - jump to answer
Answers
That certainly doesn't read easily to me:
Or in pseudo code:
That seems, unusual. Can you show me an example of the data in the table (i.e. the JSON or HTML source of the data) and your DataTable initialisation code?
Also, I'd suggest you use
column().index()
to get a column index, rather than[0][0]
(if indeed that is what is needed).Allan
Hi Allan,
You are simply amazing!
By not understanding my question, you still gave me the answer (with the reference to
columns.index()
!!idx is the number that I am interested in!!