首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编辑页脚FooTable

编辑页脚FooTable
EN

Stack Overflow用户
提问于 2018-04-06 21:45:05
回答 1查看 351关注 0票数 0

我使用FooTable 插件

在初始化之后,我尝试

代码语言:javascript
复制
  'on': {
  'postinit.ft.table': function(e, ft) {
    var
      rows = table.rows.array;
    for (var i = 0, l = rows.length, row; i < l; i++) {
      row = rows[i].val();
      total_sum += parseInt(row["sum_product"]);
      total_count += parseInt(row["count_product"]);
    }
    var foot = $("#purchases_table").find('tfoot');

    foot.prepend(
      "<tr><th rowspan=\"1\" colspan=\"1\">SUMM</th><th  rowspan=\"1\" colspan=\"3\"></th><th id='count_product_all' rowspan=\"1\" colspan=\"1\">" + total_count + "</th><th id='sum_product_all' rowspan=\"1\" colspan=\"1\">" + total_sum + "</th><th rowspan=\"1\" colspan=\"4\"></th></tr>\n");
  },   

一切都很好,我需要改变这种动态

代码语言:javascript
复制
'draw.ft.table': function(e, ft) {
  var rows = ft.rows.all;
  total_sum = 0;
  total_count = 0;
  for (var i = 0, l = rows.length, row; i < l; i++) {
    row = rows[i].val();
    total_sum += parseInt(row["sum_product"]);
    total_count += parseInt(row["count_product"]);
  }
  $("#count_product_all").html(total_count);
  $("#sum_product_all").html(total_sum);
}
},      

但是在html中,count_product_allsum_product_all只改变了1秒,然后又回到了0,为什么呢?

EN

回答 1

Stack Overflow用户

发布于 2018-04-07 00:08:57

首先,请检查是否只在$(“#count_product_all”).html(Total_count)中输入一次;请检查。

如下所示:

代码语言:javascript
复制
'draw.ft.table': function(e, ft) {
 var rows = ft.rows.all;
 bool enter = false;
 total_sum = 0;
 total_count = 0;
 for (var i = 0, l = rows.length, row; i < l; i++) {
  row = rows[i].val();
total_sum += parseInt(row["sum_product"]);
total_count += parseInt(row["count_product"]);

enter = true;
 }
 if(enter){
$("#count_product_all").html(total_count);
 $("#sum_product_all").html(total_sum);

  enter = false;
}

}
},
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49694247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档