Ver no GitHub
Bootstrap Table Uso
O plugin Bootstrap Table exibe dados em formato tabular, por meio de atributos de dados ou JavaScript.
Nesta página
Via atributos de dados
<table data-toggle="table">
<thead>
<tr>
<th>ID do Item</th>
<th>Nome do Item</th>
<th>Preço do Item</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Item 1</td>
<td>R$ 1</td>
</tr>
<tr>
<td>2</td>
<td>Item 2</td>
<td>R$ 2</td>
</tr>
</tbody>
</table>
Também podemos usar dados de URL remotos definindo data-url="data1.json" em uma tabela normal.
<table
data-toggle="table"
data-url="data1.json">
<thead>
<tr>
<th data-field="id">ID do Item</th>
<th data-field="name">Nome do Item</th>
<th data-field="price">Preço do Item</th>
</tr>
</thead>
</table>
Você também pode adicionar pagination (paginação), search (busca) e sortable (classificável) a uma tabela como a tabela a seguir.
<table
data-toggle="table"
data-url="data1.json"
data-pagination="true"
data-search="true">
<thead>
<tr>
<th data-sortable="true" data-field="id">ID do Item</th>
<th data-field="name">Nome do Item</th>
<th data-field="price">Preço do Item</th>
</tr>
</thead>
</table>
Via JavaScript
Chame uma tabela bootstrap com id table via JavaScript.
<table id="table"></table>
$('#table').bootstrapTable({
columns: [
{
field: 'id',
title: 'ID do Item'
},
{
field: 'name',
title: 'Nome do Item'
},
{
field: 'price',
title: 'Preço do Item'
}
],
data: [
{
id: 1,
name: 'Item 1',
price: 'R$ 1'
},
{
id: 2,
name: 'Item 2',
price: 'R$ 2'
}
]
})
Também podemos usar dados de URL remotos definindo url: 'data1.json'.
$('#table').bootstrapTable({
url: 'data1.json',
columns: [
{
field: 'id',
title: 'ID do Item'
},
{
field: 'name',
title: 'Nome do Item'
},
{
field: 'price',
title: 'Preço do Item'
}
]
})
Você também pode adicionar pagination (paginação), search (busca) e sortable (classificável) a uma tabela como a tabela a seguir.
$('#table').bootstrapTable({
url: 'data1.json',
pagination: true,
search: true,
columns: [
{
field: 'id',
title: 'ID do Item',
sortable: true
},
{
field: 'name',
title: 'Nome do Item'
},
{
field: 'price',
title: 'Preço do Item'
}
]
})