Oh, OK. I gotcha. I have had to do this recently and I understand your frustration. Here's what I did:
1) Go to
http://www.infopathdev.com/howto/tutorials/default.aspx?i=d663d7df90e94e65abb02632966e8127 and implement this to get a autogenerated row ID for each row in the table.
2) Make a function kind of like this to obtain the row ID:
function findRowID( item ) // any node within the table is passed in
{
var parent = item.parentNode;
// iterate up through the levels of the table until we find the ROW node
while( parent.nodeName != "my:group2" )
parent = parent.parentNode;
// when loop exits we have ROW node
var id = parent.selectSingleNode( "my:row_ID" );
return parseInteger(id.text);
}
3) Now, you should execute onAfterChange() on the ROW node, so it would be something like row::onAfterChange( eventObj ). This way if
anything in this row changes, calculate the new total. If you're looking to do the calculations in another function, simply call findRowID( eventObj.Site ), or you could pass any other node within the table, and use the rowID returned to call something like
XDocument.DOM.selectSingleNode( "//my:group1/my:group2[my:rowID = " + rowID + "]" )
The biggest help to me was the InfoPathDev tutorial. Hope this helps!
---------------
Matt Faus
Matt Faus / Microsoft InfoPath MVPQdabra® Software / Streamline data gathering to turn process into knowledge