what is your version of InDesign?
Also consider that row height could change after the gradient is applied.
E.g. text is edited. I think, every time something is done to the table, the gradient must be applied anew.
Could you share a screenshot where you see the problem with a table that is running through different text frames?
Maybe this problem also occurs, if the table flows through different columns of one single text frame?
See the following screenshot.
The first table is just one I added to the frame without doing anything in regards of row height.
A default table where I added "a" to the first cell of the second row.
I assume that you expect a result like the one at the bottom.
I think, there is more to consider than only tables that flow with more than one text frame.
FWIW: Without a character in the cell your function is not working.
Consider the baseline value of the first insertion point of a cell to start out calculating anything.
Thanks for the replies. I'm using the latest version of InDesign CC. Please see my original post regarding the need for text in the first cell of each row. The script does require that in order to calculate the page position of the row. And you are right about the need to reapply the script after the table is edited. This may limit its usefulness. But in my case the tables only extend a few pages, and the work required to reapply (and tweak) the gradients would be manageable.
Here is the script applied to a two-page table:
Left page: Perfect! Right page: Not so much. The first row is OK but then the gradient drifts upward until it disappears. I have checked the numbers calculated by the script, and the gradient start positions and lengths are correct.
And you are right about multiple-column tables. Here is a two-column table on a single page. Similar result:
Also meant to say thanks for the tip re: using the first insertion point instead of first character. I will look into that.
I can confirm your problems with table rows running in a second column or in a second text frame.
And there are odd things going on, if you change the height of the text frame and allow more or less cells flow in one column of the text frame.