Hi all,
I have a datatable built using JSF. Maximum number of rows the datatable can display is 5 and we have a datascroller to click next page.
My requirement is when I update the cell value the totals in the footer needs to be updated and I wrote JavaScript to do this and everything is working fine but when I click next the totals value is lost. My question is do I need to update this value to backing bean when I click next page??
Please look at my JavaScript code below and please give me any suggestions.
function total(){
var tr= document.getElementById(‘codForm:codData’).getElementsByTagName(‘tbody’)[0].getElementsByTagName(‘tr’);
alert(“tr length”+tr.length);
var total1=total2=total3=total4=0;
for(var i=0; i<tr.length; i++) {
var td=tr[i].getElementsByTagName(‘td’);
total1+=parseFloat(td[1].firstChild.value);
total2+=parseFloat(td[2].firstChild.value);
total3+=parseFloat(td[3].firstChild.value);
total4+=parseFloat(td[4].firstChild.value);
}
var el=document.getElementById(‘col1Footer’);
el.firstChild.data=total1;
var el1=document.getElementById(‘col2Footer’);
el1.firstChild.data=total2;
var el2=document.getElementById(‘col3Foter’);
el2.firstChild.data=total3;
var el3=document.getElementById(col4Footer’);
el3.firstChild.data=total4;
}
And my data table code in my jsp is:
<t:dataTable id=”codData” styleClass=”resultTable”
var=”codRecord” value=”#{tempBean.myList}” preserveDataModel=”false” rows=”5″ rowIndexVar=”rowIndex” frame=”border”>
please suggest.