【问题标题】:bootstrapTable header columns appearing twicebootstrapTable 标题列出现两次
【发布时间】:2015-04-30 17:01:43
【问题描述】:

这是正在发生的事情

我不明白为什么列中的标题会这样出现两次。我在其他页面上有相同的代码,但它没有这样做。

JQUERY

var $table = $('#table-javascript').bootstrapTable({
    method: 'get',
    url: 'bootstrap_database_email_history.php',
    height: 300,
    cache: false,
    striped: true,
    pagination: true,
    search: false,
    pageSize: 20,
    pageList: [20, 40, 60, 100, 200],
    minimumCountColumns: 2,
    clickToSelect: true,
    columns: [{
        field: 'date',
        title: 'Date',
        align: 'left',
        width: '100'
    },{
        field: 'email', 
        title: 'Email',
        align: 'left',
        width: '20'
    },{
        field: 'sent',
        title: 'Sent',
        align: 'center',
        width: '20'
    },{
        field: 'notsent',
        title: 'Not Sent',
        align: 'center',
        width: '20'
    }]
});

HTML

<table id="table-javascript"></table>

bootstrap_database_email_history.php

<?
include('../includes/connect.php');
$sql = "SELECT * FROM table WHERE this = '$this' ORDER BY ID DESC";
$result = mysql_query($sql);
$records = mysql_num_rows($result);
if ($records == 0) {
    $data['posts'][$i] = $response[$i];
}
$i = 0;
while ($row = mysql_fetch_array($result)) {
    $response[$i]['date'] = $row['date'];
    $response[$i]['email'] = $row['email'];
    $response[$i]['sent'] = $row['sent'];
    $response[$i]['notsent'] = $row['notsent'];
    $data['posts'][$i] = $response[$i];
    $i = $i+1;
    unset($slot);
}
echo json_encode($data['posts']);
?>

JSON 响应

[{
    "date":"04\/30\/15",
    "email":"user@user.com",
    "sent":"<\/i>",
    "notsent":""
},{
    "date":"04\/30\/15",
    "email":"user@leader.com",
    "sent":"<\/i>",
    "notsent":""
},{
    "date":"04\/30\/15",
    "email":"user@admin.com",
    "sent":"<\/i>",
    "notsent":""
}]

【问题讨论】:

  • 第一个block中的JQuery代码会不会被多次调用?周围会发生什么?是顶级代码行吗?
  • 如果你能提供来自 bootstrap_database_email_history.php 的示例 json 会更容易
  • 我是这么想的,但是我在函数中设置了一个警报,它只警报一次。
  • 添加了 JSON 响应 @MaciejKwas

标签: jquery twitter-bootstrap bootstrap-table


【解决方案1】:

对我来说,您似乎没有附加 css 文件,我可能是错的,但这个例子很有效:Demo

var json = [{
    "date":"04\/30\/15",
    "email":"user@user.com",
    "sent":"<\/i>",
    "notsent":""
},{
    "date":"04\/30\/15",
    "email":"user@leader.com",
    "sent":"<\/i>",
    "notsent":""
},{
    "date":"04\/30\/15",
    "email":"user@admin.com",
    "sent":"<\/i>",
    "notsent":""
}];

$('#table-javascript').bootstrapTable({
    data: json,
    height: 300,
    striped: true,
    pagination: true,
    search: false,
    pageSize: 20,
    pageList: [20, 40, 60, 100, 200],
    minimumCountColumns: 2,
    clickToSelect: true,
});

【讨论】:

  • 轰隆隆!你这个男人,我讨厌它这么简单,我想念它
猜你喜欢
  • 1970-01-01
  • 2023-03-05
  • 2020-09-09
  • 1970-01-01
  • 2017-07-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多