Rebooting in jQuery BootGrid not working

I have a problem reloading ajax data in bootgrid ( http://www.jquery-bootgrid.com/ )

I have successfully prepared the grid for display at all, but if I add an element to db, I want to reload the grid.

my code is now this (abbreviated):

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 the grid variable is global and accessible everywhere. but the reload function is documented here: http://www.jquery-bootgrid.com/Documentation#methods does not work, and I have the ajax parameter set to true

Any tips?

Thanks and sorry for my english

+5
source share
3 answers

Have you tried:

 $('#grid-data').bootgrid('reload'); 

Ajax request loaded for me

+8
source

So, I finished this task myself :-)

I do not use the grid.reload () method, but after saving ajax, call easily:

 $('button[title=Refresh]').click(); 
+2
source

Change the following in a jquery.bootgrid.js script fragment

  Grid.prototype.reload = function() { this.current = 1; // reset loadData.call(this); return this; }; 

change to:

 Grid.prototype.reload = function(current) { this.current = (current !== 'undefined') ? current : 1; loadData.call(this); return this; }; 
0
source

Source: https://habr.com/ru/post/1201578/


All Articles