Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootgrid append method

Im breaking my head and cant figure out how to append data, just for testing pourpuses i did this :

              var JSONINFO = {"rows": [{"id": 19, "sender": "[email protected]", "received": "2014-05-30T22:15:00", "status":"Garantia"},{"id": 19, "sender": "[email protected]", "received": "2014-05-30T22:15:00", "status":"Garantia"} ]};

              var result = [];
              for(var i in JSONINFO) result.push([i, JSONINFO [i]]);
              $("#grid-basic").bootgrid().bootgrid("append",result.rows);

but cannot insert data in the table ... can anyone clarify the format that the array should have ?, or a more comprehensive example? ... Thanks a lot !

like image 462
Sebastian Davicco Avatar asked Jul 13 '15 21:07

Sebastian Davicco


3 Answers

I had the same problem with my grid. The problem was that I was loading my grid with ajax.

Removing the ajax: true and/or setting it to the default false solved the "append", "remove" and "clear" problem but I had to solve the loading problem.

In my case, I decided not using the grid "append" function and reload the grid data with a server side call. $("#myGrid").bootgrid('reload')

I am not happy with the solution but at least I found the problem I had

var grid = $("#myGrid").bootgrid({
        ajax: false,                    
                formatters: {
            "commands": function (column, row) {
                return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.id + "\"><span class=\"fa fa-pencil\"></span></button> " +
                    "<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.id + "\"><span class=\"fa fa-trash-o\"></span></button>";
            }
        }
    })
like image 77
Guish Avatar answered Jan 01 '23 13:01

Guish


Just use it like this:

var JSONINFO = {"rows": [{"id": 19, "sender": "[email protected]", "received": "2014-05-30T22:15:00", "status":"Garantia"},{"id": 19, "sender": "[email protected]", "received": "2014-05-30T22:15:00", "status":"Garantia"} ]};

$("#grid-basic").bootgrid("append", JSONINFO.rows);
like image 41
Alisson Reinaldo Silva Avatar answered Jan 01 '23 12:01

Alisson Reinaldo Silva


Try replacing:

bootgrid("append",result.rows);

with:

bootgrid("append",result.d);
like image 45
gabriel Avatar answered Jan 01 '23 13:01

gabriel