How to update the table (bootstrap-table) via JS after registration?

3

Once you register (within a modal), the table must be updated automatically. But I can not. NOTE: Languages I'm using are PHP and JS.

In jsfiddle, there is a small demonstration, in the JS tab is the (else) code that I am trying to do to update the bootstrap-table query.

link

    
asked by anonymous 12.02.2016 / 18:07

3 answers

0

Well, you can use an ajax request for the form, where the return of this ajax will be the list of the updated table, so you only need to update the table fields with the ajax return.

    
18.02.2016 / 20:31
0

You can use ajax:

$("#adicionar").click(function()
{
    $.ajax({
        type: 'POST',
        url: 'adicionar.php',
        success: function(data)
        {
            $(".table").append(data);
        }
    });
});

#addition - > The id of a button that should be included to perform the action
Type - > Method of sending information
URL - > The function made in php that will be responsible for including in your table
.Table - > the table class where the result of the previous function will be sent

To show the information you can use echo same, there you go.

    
29.06.2017 / 18:25
-1

Hey!

I saw in jsfiddle that you are mounting the table with while .. I think it's worth changing and letting the bootstra-table mount the table for you, it's simple:

Create a PHP file that returns a json with the table data, and throw the path of that file inside the data-url attribute in the table tag, like this:

> <table id="table-nome"
>   data-url="caminho_data.php"
> >
> <thead>
>   <tr>
>       <th data-field="campo1">Campo 1</th>
>       <th data-field="campo 2">Campo 2</th>
>   </tr>
> </thead>
> </table>

Then, after saving the information in its modal, in the ajax return, just call:

$("#table-nome").bootstrapTable('refresh');

You can see an example here:

[ link

There are several other examples on this site, take a look, the bootstrap-table has a lot of legal functionality that makes life much easier once you get the hang of it;)

o /

Another solution, GAMBIS in my view, is to play the table in another file and call that file again in the ajax return of the modal action, and replace the current table ...

    
23.01.2017 / 19:02