gpt4 book ai didi

jquery - 编辑页脚 FooTable

转载 作者:行者123 更新时间:2023-11-28 01:54:59 24 4
gpt4 key购买 nike

我使用 FooTable 插件

初始化后我尝试

  '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");
},

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

'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 为什么?

enter image description here

最佳答案

首先,你可以检查是否只输入一次 $("#count_product_all").html(total_count);请。

像这样:

'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;
}

}
},

关于jquery - 编辑页脚 FooTable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49694247/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com