Bootgrid add method
I'm racking my brains and can't figure out how to add data, just for testing pourpuses I did this:
var JSONINFO = {"rows": [{"id": 19, "sender": "123@test.de", "received": "2014-05-30T22:15:00", "status":"Garantia"},{"id": 19, "sender": "123@test.de", "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 can't insert data into table ... can anyone elaborate on the format the array should have? or a more complete example? ... Thanks a lot!
source to share
I had the same problem with my grid. The problem was I was loading my grid using ajax.
Uninstalling ajax: true
and / or installing it by default false
resolved the add, remove, and clean issue, but I had to fix the boot problem.
In my case, I decided not to use the "add" grid 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 that the problem I had was
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>";
}
}
})
source to share
Just skip JASON
var JSONINFO = [{"id": 19, "sender": "123@test.de", "received": "2014-05-30T22:15:00", "status":"Garantia"},{"id": 19, "sender": "123@test.de", "received": "2014-05-30T22:15:00", "status":"Garantia"} ];
grid.bootgrid("append", JSONINFO);
Note the removal of "rows" from JASON ...
source to share
Just use it like this:
var JSONINFO = {"rows": [{"id": 19, "sender": "123@test.de", "received": "2014-05-30T22:15:00", "status":"Garantia"},{"id": 19, "sender": "123@test.de", "received": "2014-05-30T22:15:00", "status":"Garantia"} ]};
$("#grid-basic").bootgrid("append", JSONINFO.rows);
source to share