content logo

Bootstrap Tables:

Bootstrap Table with Export Option

Good table user interface designs are able to visualize web data in a nice and clean format which enables the users to scan, analyse, sort, filter and compare them and finally decide on what action to take. In the industry of web design, tables are literally tools that use rows and columns to show various information and interface data in a grid or list layout. In other words, designers use tables to present any information, especially more complicated ones, from different sections of the site, for example the pricing page, dashboard, delivery page and more, in a more stylish and professional method. So, the table designs are often chosen to achieve a simple and intuitive way to list important data.

Due to the important nature of the data inside these tables, some may want to export them. The code below features a Bootstrap export table that is designed for this sole reason. Of course, it also supports a basic filter option so you can search for your data more easily in case the list was too long to go through. Having this responsive Bootstrap table helps anyone with any device to use your website. The unique feature in this Bootstrap table is the export table option which allows you to output several formats.

#

Bootstrap Table

#

Bootstrap Export Table

#

Export Table Option

#

Responsive Bootstrap Table


<!-- This script got from frontendfreecode.com -->
<div class="container">
	<h1>Bootstrap Table</h1>
	<div id="toolbar">
		<select class="form-control">
			<option value="">Export Basic</option>
			<option value="all">Export All</option>
			<option value="selected">Export Selected</option>
		</select>
	</div>
	<table id="table"
		   data-toggle="table"
		   data-search="true"
		   data-filter-control="true"
		   data-show-export="true"
		   data-click-to-select="true"
		   data-toolbar="#toolbar">
		<thead>
			<tr>
				<th data-field="state" data-checkbox="true"></th>
				<th data-field="prenom" data-filter-control="input" data-sortable="true">Prénom</th>
				<th data-field="date" data-filter-control="select" data-sortable="true">Date</th>
				<th data-field="examen" data-filter-control="select" data-sortable="true">Examen</th>
				<th data-field="note" data-sortable="true">Note</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td class="bs-checkbox "><input data-index="0" name="btSelectItem" type="checkbox"></td>
				<td>Valérie</td>
				<td>01/09/2015</td>
				<td>Français</td>
				<td>12/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="1" name="btSelectItem" type="checkbox"></td>
				<td>Eric</td>
				<td>05/09/2015</td>
				<td>Philosophie</td>
				<td>8/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="2" name="btSelectItem" type="checkbox"></td>
				<td>Valentin</td>
				<td>05/09/2015</td>
				<td>Philosophie</td>
				<td>4/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="3" name="btSelectItem" type="checkbox"></td>
				<td>Valérie</td>
				<td>05/09/2015</td>
				<td>Philosophie</td>
				<td>10/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="4" name="btSelectItem" type="checkbox"></td>
				<td>Eric</td>
				<td>01/09/2015</td>
				<td>Français</td>
				<td>14/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="5" name="btSelectItem" type="checkbox"></td>
				<td>Valérie</td>
				<td>07/09/2015</td>
				<td>Mathématiques</td>
				<td>19/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="6" name="btSelectItem" type="checkbox"></td>
				<td>Valentin</td>
				<td>01/09/2015</td>
				<td>Français</td>
				<td>11/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="7" name="btSelectItem" type="checkbox"></td>
				<td>Eric</td>
				<td>01/10/2015</td>
				<td>Philosophie</td>
				<td>8/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="8" name="btSelectItem" type="checkbox"></td>
				<td>Valentin</td>
				<td>07/09/2015</td>
				<td>Mathématiques</td>
				<td>14/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="9" name="btSelectItem" type="checkbox"></td>
				<td>Valérie</td>
				<td>01/10/2015</td>
				<td>Philosophie</td>
				<td>12/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="10" name="btSelectItem" type="checkbox"></td>
				<td>Eric</td>
				<td>07/09/2015</td>
				<td>Mathématiques</td>
				<td>14/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="11" name="btSelectItem" type="checkbox"></td>
				<td>Valentin</td>
				<td>01/10/2015</td>
				<td>Philosophie</td>
				<td>10/20</td>
			</tr>
		</tbody>
	</table>
</div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
.container {
    padding: 2em;
}

.bold-blue {
    font-weight: bold;
    color: #0277BD;
}
var $table = $('#table');
$(function () {
    $('#toolbar').find('select').change(function () {
        $table.bootstrapTable('refreshOptions', {
            exportDataType: $(this).val()
        });
    });
})
var trBoldBlue = $("table");
$(trBoldBlue).on("click", "tr", function () {
    $(this).toggleClass("bold-blue");
});
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.0/bootstrap-table.min.css'>
<link rel='stylesheet' href='https://rawgit.com/vitalets/x-editable/master/dist/bootstrap3-editable/css/bootstrap-editable.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.0/bootstrap-table.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/editable/bootstrap-table-editable.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/export/bootstrap-table-export.js'></script>
<script src="http://frontendfreecode.com/codes/files/tableExport.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/filter-control/bootstrap-table-filter-control.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.0/bootstrap-table.min.css'>
<link rel='stylesheet' href='https://rawgit.com/vitalets/x-editable/master/dist/bootstrap3-editable/css/bootstrap-editable.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.0/bootstrap-table.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/editable/bootstrap-table-editable.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/export/bootstrap-table-export.js'></script>
<script src="http://frontendfreecode.com/codes/files/tableExport.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/filter-control/bootstrap-table-filter-control.js'></script>
<style>
.container {
    padding: 2em;
}

.bold-blue {
    font-weight: bold;
    color: #0277BD;
}
</style>

</head>
<body>
<div class="container">
	<h1>Bootstrap Table</h1>
	<div id="toolbar">
		<select class="form-control">
			<option value="">Export Basic</option>
			<option value="all">Export All</option>
			<option value="selected">Export Selected</option>
		</select>
	</div>
	<table id="table"
		   data-toggle="table"
		   data-search="true"
		   data-filter-control="true"
		   data-show-export="true"
		   data-click-to-select="true"
		   data-toolbar="#toolbar">
		<thead>
			<tr>
				<th data-field="state" data-checkbox="true"></th>
				<th data-field="prenom" data-filter-control="input" data-sortable="true">Prénom</th>
				<th data-field="date" data-filter-control="select" data-sortable="true">Date</th>
				<th data-field="examen" data-filter-control="select" data-sortable="true">Examen</th>
				<th data-field="note" data-sortable="true">Note</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td class="bs-checkbox "><input data-index="0" name="btSelectItem" type="checkbox"></td>
				<td>Valérie</td>
				<td>01/09/2015</td>
				<td>Français</td>
				<td>12/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="1" name="btSelectItem" type="checkbox"></td>
				<td>Eric</td>
				<td>05/09/2015</td>
				<td>Philosophie</td>
				<td>8/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="2" name="btSelectItem" type="checkbox"></td>
				<td>Valentin</td>
				<td>05/09/2015</td>
				<td>Philosophie</td>
				<td>4/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="3" name="btSelectItem" type="checkbox"></td>
				<td>Valérie</td>
				<td>05/09/2015</td>
				<td>Philosophie</td>
				<td>10/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="4" name="btSelectItem" type="checkbox"></td>
				<td>Eric</td>
				<td>01/09/2015</td>
				<td>Français</td>
				<td>14/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="5" name="btSelectItem" type="checkbox"></td>
				<td>Valérie</td>
				<td>07/09/2015</td>
				<td>Mathématiques</td>
				<td>19/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="6" name="btSelectItem" type="checkbox"></td>
				<td>Valentin</td>
				<td>01/09/2015</td>
				<td>Français</td>
				<td>11/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="7" name="btSelectItem" type="checkbox"></td>
				<td>Eric</td>
				<td>01/10/2015</td>
				<td>Philosophie</td>
				<td>8/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="8" name="btSelectItem" type="checkbox"></td>
				<td>Valentin</td>
				<td>07/09/2015</td>
				<td>Mathématiques</td>
				<td>14/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="9" name="btSelectItem" type="checkbox"></td>
				<td>Valérie</td>
				<td>01/10/2015</td>
				<td>Philosophie</td>
				<td>12/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="10" name="btSelectItem" type="checkbox"></td>
				<td>Eric</td>
				<td>07/09/2015</td>
				<td>Mathématiques</td>
				<td>14/20</td>
			</tr>
			<tr>
				<td class="bs-checkbox "><input data-index="11" name="btSelectItem" type="checkbox"></td>
				<td>Valentin</td>
				<td>01/10/2015</td>
				<td>Philosophie</td>
				<td>10/20</td>
			</tr>
		</tbody>
	</table>
</div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
var $table = $('#table');
$(function () {
    $('#toolbar').find('select').change(function () {
        $table.bootstrapTable('refreshOptions', {
            exportDataType: $(this).val()
        });
    });
})
var trBoldBlue = $("table");
$(trBoldBlue).on("click", "tr", function () {
    $(this).toggleClass("bold-blue");
});
</script>

</body>
</html>
Preview