views:

57

answers:

1

I want to keep my total sum every time I sort my column from my table

<thead>
  <tr class="titlerow">
    <th></th>
    <th></th>
    <th align="left">
      <asp:LinkButton ID="Programs" runat="server" CommandArgument="Asc" 
                      CommandName="G1" CssClass="table-sort active"
                      OnClick="Programs_Click" 
                      Text="Campaign">
      </asp:LinkButton>
    </th>                   
    <th align="center">
      <asp:LinkButton ID="DateId" runat="server" CommandArgument="Asc" 
                      CommandName="Date" OnClick="Programs_Click"
                      Text="Start Date">
      </asp:LinkButton>
    </th>
    <th align="center">
      <asp:LinkButton ID="SentId" runat="server" CommandArgument="Asc" 
                      CommandName="Sent" OnClick="Programs_Click"
                      Text="Sent">
      </asp:LinkButton>
    </th>
    <th align="center">
      <asp:LinkButton ID="SuccessId" runat="server" CommandArgument="Asc" 
                      CommandName="Success" CssClass="table-sort active"                          
                      OnClick="Programs_Click"
                      Text="Success">
      </asp:LinkButton>
    </th>
    <th align="center">
      <asp:LinkButton ID="PerSuccess" runat="server" CommandArgument="Asc" 
                      CommandName="PerSuccess" CssClass="table-sort active" 
                      OnClick="Programs_Click" Text="(%)">
      </asp:LinkButton>
    </th>

    <th align="center">
      <asp:LinkButton ID="HardbounceId" runat="server" CommandArgument="Asc" 
                      CommandName="Hardbounce" CssClass="table-sort active" OnClick="Programs_Click" 
                      Text="Hardbounce"></asp:LinkButton>
    </th>
    <th align="center">
      <asp:LinkButton ID="PerHardbounce" runat="server" CommandArgument="Asc" 
                      CommandName="PerHardbounce" CssClass="table-sort active" OnClick="Programs_Click" 
                      Text="(%)"></asp:LinkButton>
    </th>

This script will calculate the SumOfcolumn:

$(document).ready(function() {
  $("#Sent").html(sumOfColumns("firstData", 5, false));
  $("#Success").html(sumOfColumns("firstData", 6, false));
  $("#SuccessPer").html(
    (sumOfColumns("firstData", 6, false) * 100/sumOfColumns("firstData", 5, false)).toFixed(2) + "%"
  );
  $("#Hardbounce").html(sumOfColumns("firstData", 8, false));
  $("#HardbouncePer").html(
    (sumOfColumns("firstData", 8, false) * 100/sumOfColumns("firstData", 5, false)).toFixed(2) + "%"
  );   
});

and display the data in the following table

<tfoot>
  <tr class="totalrow">
    <th></th>
    <th></th>
    <th align="left">Total</th>
    <th></th>
    <th align="center" id="Sent"></th>
    <th align="center" id="Success"></th>
    <th align="center" id="SuccessPer"></th>
    <th align="center" id="Hardbounce"></th>
    <th align="center" id="HardbouncePer"></th>
</tfoot>
<table>

Anyone know how to prevent the row data from disapearing?

+1  A: 

No worries. I solve the issue. The problem was sending the data back to the server side very helpfull link was fund on http://davidz.afriklink.com/post/Sum-Table-Column-using-JQuery.aspx

FasoService