agregar en linea datos a boostrap table
:)
by Felipe Zura
HTML
<link rel="stylesheet" href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css">
<script src="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.js"></script>
<div class="container">
<h1>append</h1>
<p>Append the data to table: <code>$table.bootstrapTable('append', data);</code></p>
<div id="toolbar">
<button id="button" class="btn btn-default">append</button>
<button id="button1" class="btn btn-default">get</button>
<input type="text" id="valor_name">
</div>
<table id="table"
data-toggle="table"
data-height="200">
<thead>
<tr>
<th data-field="name">Name</th>
<th data-field="stargazers_count">Stars</th>
<th data-field="forks_count">Forks</th>
<th data-field="description">Description</th>
<th data-field="boton"></th>
</tr>
</thead>
</table>
</div>
JavaScript
var $table = $('#table'),
$button = $('#button');
$(function () {
$button.click(function () {
$table.bootstrapTable('append', agregar_producto());
$table.bootstrapTable('scrollTo', 'bottom');
$('#valor_name').val('');
});
});
function agregar_producto() {
rows = [];
var varlor_name=$('#valor_name').val();
rows.push({
name: varlor_name,
stargazers_count: '$',
forks_count:'1',
description:'dsaasd'
});
return rows;
}
$('#button1').click(function () {
alert(JSON.stringify($table.bootstrapTable('getData')));
});