0
Next, in the rows of my table bootstrap
when I click opens a modal
where I can change the selected information after click. I wanted that right after I clicked on the change button, my table (and only her) updated without I need to give a "refresh
on the whole page". I tried with the 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>
As you change this data, they go to which place, a variable database as you work that information. The update should also be called when you close the modal and not at the same time it opens ...
– novic
So I’m using the mvc method... so I call an action in the controller I created to update and then send it to Sqlserver with json and such...
– Marcos Henrique