5

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": "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 cannot insert data in the table ... can anyone clarify the format that the array should have ?, or a more comprehensive example? ... Thanks a lot !

4 Answers4

3

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>";
            }
        }
    })
Guish
  • 4,968
  • 1
  • 37
  • 39
2

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);
Alisson Reinaldo Silva
  • 10,009
  • 5
  • 65
  • 83
1

Try replacing:

bootgrid("append",result.rows);

with:

bootgrid("append",result.d);
Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
gabriel
  • 11
  • 1
1

Just pass 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);

Pay attention to remove "rows" from JASON...

SauloRJ
  • 23
  • 6