jquery - How to get a sum of column of GridView using JavaScript -


i'm trying access column named time of gridview , calculate sum of whole column using javascript.

i have this:

enter image description here

so in report total want number 5, since entry right now.

this definition of gridview:

<div class="total">      <asp:gridview id="reportgrid" runat="server" autogeneratecolumns="false" datasourceid="sqlds" height="68px" width="813px" allowpaging="true">         <columns>             <asp:boundfield datafield="date" headertext="date" sortexpression="date" dataformatstring="{0:mm/dd/yy}" />             <asp:boundfield datafield="name" headertext="team member name" sortexpression="name" />             <asp:boundfield datafield="projectname" headertext="projects" sortexpression="projectname" />             <asp:boundfield datafield="description" headertext="description" sortexpression="description" />             <asp:boundfield datafield="time" headertext="time" sortexpression="time" />         </columns>     </asp:gridview>     <br />     <br />     <span>report total: <em>         <asp:label runat="server" id="totalhours" text="0"></asp:label></em></span> </div> 

can me javascript code problem or share me related links, cause i've found on internet wasn't similar this, , guess simple thing when know how use js.

nan value sum during debugging:

enter image description here

add css class fields

    <asp:boundfield datafield="time" headertext="time">        <itemstyle cssclass="yourclass"></itemstyle>       </asp:boundfield>  

and use following code

 var fields= document.getelementsbyclassname('yourclass');     var sum = 0;     (var = 0; < fields.length; ++i) {         var item = fields[i];            sum += parseint(item.innerhtml);     } 

and assign sum total label

$("#<%= totalhours.clientid %>").text(sum); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -