Hi,
Using JDeveloper 11.1.1.2.0. I have several tables where I need to display a calculated sum of values in a column beneath the table with the calculated values updating dynamically on value changes. I could do this in a backing bean but communicating with the server on each value change (ie. using the arrows on a spinbox) would be quite inefficient. I added a client listener to the input field and was able to get the handle to the table in JavaScript but am completely lost on how to iterate over the rows and calculate the sum.
This is the code I have so far, based on [Frank“s JavaScript tips|http://thepeninsulasedge.com/frank_nimphius/adf-faces-rich-client-javascript-programming/] :
// event is a valueChangeEvent from the input field
function calculateSum(event) {
var _theTable = event.getSource().getParent();
var sum = 0;
for(var i = 0; i < _theTable.getRows(); i++){
// what to do here???
sum += ?someRowVar?.findComponent("percentage").getValue();
}
var total = _theTable.findComponent("totalSum");
totalSum.setValue(sum);
Can I get the RowKeySet for the table somehow?
Any suggestions?
Regards,
Joonas