minor improvement: calculate index based on the element's parent th. this is better because it allows to have some columns that are not searchable (like when the first row is a checkbox row)