.index with context

.index with context

I am working on a grid widget and I recently found an issue with my code when grouping columns. The grid displays the data inside a table element where each row that display's the model's data has a class called .data-row. This allows a row that actually contains model data to be easily distinguished from rows used to show group headers or aggregates, etc.

When running my tests, I found that when there is more than one grid on the page, the .index() function doesn't maintain context. When editing a cell in a grouped row, my grid needs to know what the index of the row is in order to update the date source properly. It does this by getting the current td's parent row, and then finding that row's index among the other .data-row tr's.

However, since the .index() function doesn't retrieve the context from the jQuery object that it was called from, when there is more than one grid widget on the page, the .index function uses the document as the context and will return the index relative to all .data-row tr's on the page rather than just the single grid that is being edited.

I know that the context has been deprecated, but is there any easy, jQuery-type solution to this without hacking jQuery to get .index() to maintain the context in which it was called?