2015-04-30 23 views
3

这里bootstrapTable标题列是发生了什么出现两次

bootstrap header columns

我无法弄清楚,为什么在列的标题都是这样出现两次。我在其他页面上有相同的代码,但它不这样做。

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":"[email protected]", 
    "sent":"<\/i>", 
    "notsent":"" 
},{ 
    "date":"04\/30\/15", 
    "email":"[email protected]", 
    "sent":"<\/i>", 
    "notsent":"" 
},{ 
    "date":"04\/30\/15", 
    "email":"[email protected]", 
    "sent":"<\/i>", 
    "notsent":"" 
}] 
+0

是否有可能JQuery的第一个程序段中的代码被多次调用?它周围会发生什么?它是顶级的代码行吗? –

+0

如果你能提供来自bootstrap_database_email_history.php –

+0

的样本json,这就是我的想法,但我在函数中放置了一个警报,它只会警告一次,会更容易。 –

回答

4

对于我来说,它看起来像你有没有附加的CSS文件,我可能是错的,但这个例子只是工作:Demo

var json = [{ 
    "date":"04\/30\/15", 
    "email":"[email protected]", 
    "sent":"<\/i>", 
    "notsent":"" 
},{ 
    "date":"04\/30\/15", 
    "email":"[email protected]", 
    "sent":"<\/i>", 
    "notsent":"" 
},{ 
    "date":"04\/30\/15", 
    "email":"[email protected]", 
    "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, 
}); 
+0

BOOM!你是那个男人,当它那么简单,我想念它的时候,我讨厌它 –