四方显神

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

解决bootstraptable只能初始化数据一次的问题

ajax+bootstraptable展示数据的时候,无法根据需求更改展示内容,报错:You cannot initialize the table more than once!

解决方案:

加一行代码,先将bootstraptable销毁

$("#tool1table").bootstrapTable('destroy');

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<script>
    $("#tool1btn").click(function () {
 
        if ($("#tool1select_gene").val() == "" && $("#tool1select_disease").val() == "") {
            alert("Please select a dataset or gene name for analysis.")
        } else {
            $.ajax({
                type: 'POST',
                dataType: 'json',
                data: {
                    symbol: $("#tool1select_gene").val(),
                    disease: $("#tool1select_disease").val()
                },
                url: '/cuDB/analysis/differential/result',
                success: function (diff_return) {
                    const return_data = JSON.parse(JSON.stringify(diff_return));
                    $("#tool1table").bootstrapTable('destroy');
                    {#$("#tool1table").bootstrapTable('refresh'); //亲测重新刷新不可以,只能销毁 #}
                    $("#tool1table").bootstrapTable({
                        columns: [{
                            field: 'symbol',
                            title: 'Symbol',
                            sortable: true
                        }, {
                            field: 'disease',
                            title: 'Disease',
                            sortable: true
                        }, {
                            field: 'log_fc',
                            title: 'logFC',
                            sortable: true
                        }, {
                            field: 'p_value',
                            title: 'p value',
                            sortable: true
                        },
                            {
                                field: 'rid',
                                title: 'More<br>Details',
                                align: 'center',
                                {#formatter: detailFormatter,#}
                            },
                        ],
                        data: return_data,
                    });
                },
                error: function () {
                    console.log("出问题咯error")
                }
            });
        }
    });
</script>

 

posted on   szdbjooo  阅读(114)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
历史上的今天:
2020-09-21 数据结构007_中缀转后缀表达式
2020-09-21 插播一条:ASCII码
2020-09-21 数据结构006_逆波兰计算器分析和实现
2020-09-21 插播一条:常用正则表达式
点击右上角即可分享
微信分享提示