Next in the lines of my bootstrap
table when I click opens a modal
where I can change the selected information after click. I wanted that right after I clicked the button to change, my table (and only it) would update without needing to give a " refresh
on the whole page". I've tried Javascript
down but nothing happens.
var dados = [];
var $myModal = $('#myModal');
var btnAltera = $('#btn-altera');
var $table = $('#table-forms');
$(document).ready(function(){
$.get('/Formulario/SelecionarFormularios', function(data){
if (data != null){
var Formularios = data.data;
$.each(Formularios, function (i, data) {
var forms = {
id: data.IdFormulario,
idempresa: data.IdEmpresa,
nomeform: data.NomeFormulario,
nomeempresa: data.Empresa.Nome,
logopath: data.Empresa.LogoPath,
}
dados.push(forms);
});
}
});
setTimeout(function () {
$table.bootstrapTable({
data: dados,
pagination: true,
pageSize: 10,
search: true,
showRefresh: true,
showExport: true,
sidePagination: 'client',
dataClickToSelect: true,
columns: [
{
title: 'ID',
field: 'id',
align: 'center',
sortable: true,
},
{
title: 'IDEMPRESA',
field: 'idempresa',
align: 'center',
sortable: true,
},
{
title: 'NOME FORMULÁRIO',
field: 'nomeform',
align: 'center',
sortable: true,
},
{
title: 'EMPRESA',
field: 'nomeempresa',
align: 'center',
sortable: true,
},
{
title: 'LOGO-URL',
field: 'logopath',
align: 'center',
sortable: true,
},
]
}).on('click-row.bs.table', function (e, row, $element) {
$('#id').val(row.id);
$('#nomeform').val(row.nomeform);
$('#nomeempresa').val(row.nomeempresa);
$('#empresamodal').val(row.nomeempresa);
$('#logopath').val(row.logopath);
var BotstrapDialog = $myModal;
BotstrapDialog.modal({
show: 'false'
});
btnAltera.click(function () {
AlterarFormulario();
$table.bootstrapTable('refresh', {
url: '/Formulario/Formulario'
});
});
});
}, 200);
function AlterarFormulario() {
$.post('/Formulario/AlterarFormulario', {
IdFormulario: $('#id').val(),
NomeFormulario: $('#nomeform').val(),
});
}
});
Html:
<div class="row">
<table id="table-forms" class="table table-bi table-hover" style="table-layout:auto;">
</table>
</div>