2015-04-30 99 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!你是那個男人,當它那麼簡單,我想念它的時候,我討厭它 –