BootstrapTable start columns render twice
Here's what's going on
I can't figure out why the headers in the columns appear twice. I have the same code on other pages and it doesn't.
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']);
?>
ANSWER JSON RESULTS
[{
"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":""
}]
+3
source to share
1 answer
For me it looks like you haven't linked the css file, I may be wrong, but this example only works: 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,
});
+4
source to share