i have problem with reloading ajax data in bootgrid (http://www.jquery-bootgrid.com/)
i have successfully prepared grid to display at all, but if i add item to db, i want make reload of the grid.
my code is now this (shortened):
var grid;
$(document).ready(function() {
grid = initGrid();
});
function initGrid() {
var local_grid = $('#clients-grid').bootgrid({
"ajax": true,
"url": "/client/grid",
"formatters": {
"commands": function(column, row) {
return "<button type=\"button\" class=\"btn btn-default command-edit\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-pencil\"></span></button> " +
"<button type=\"button\" class=\"btn btn-default command-delete\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-trash\"></span></button> " +
"<button type=\"button\" class=\"btn btn-default command-mail\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-envelope\"></span></button>";
},
"tooltips": function(column,row) {
return '<span type="button" class="content-popover" title="'+row.name+'" data-content="'+row.content+'">Najeďte myší pro zobrazení obsahu</span>';
},
"clientname": function(column,row) {
return row.name;
}
}
}).on("loaded.rs.jquery.bootgrid", function() {
$('.content-popover').popover({
trigger: 'hover',
html: true,
placement: 'right',
content: $(this).attr('data-content')
});
grid.find(".command-edit").on("click", function(e) {
editClient($(this).data('row-id'));
}).end().find(".command-delete").on("click", function(e) {
var id = $(this).data('row-id');
if (confirm('Opravdu smazat klienta s ID: '+$(this).data("row-id")+'?')) {
deleteClient($(this).data('row-id'));
}
}).end().find(".command-mail").on("click", function(e){
mailClient($(this).data('row-id'));
});
});
return local_grid;
}
so grid variable is in global and is accessible from everywhere.. but function reload documented here: http://www.jquery-bootgrid.com/Documentation#methods not working, and i have ajax parameter set on true
Any advice?
Thanks and sorry for my english
Did you try:
$('#grid-data').bootgrid('reload');
For me the ajax request is loaded
So i finished this task myself :-)
I do not using grid.reload() method, but after ajax save, call easily:
$('button[title=Refresh]').click();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With