JqGrid reloadGrid and update new colModel and colNames

I am trying to reload jqGrid with new lines, colNames and colModel. It seems that these rows load normally, but the columns do not seem to be updated. I tried using GridUnload and GridDestroy, but in the end I completely lost an instance of the JQuery DOM and no longer loaded data.

var grid = $('#my-grid');

if(grid[0].grid == undefined) {
    grid.jqGrid(options);
} else {
    grid.setGridParam(options);
    grid.trigger('reloadGrid');
}

A grid instance is important because it will be passed to other objects as a parameter. These objects can join listeners or trigger events.

I am using version 4.4.2

+5
source share
3 answers

It seems that jqGrid removes the original <table></table>from the DOM and replaces it or forgets the link (I did not see that it is difficult).

, , , .. $('table#my-grid'). , .

div . jqGrid colModel colNames.

grid.empty();
delete grid[0].grid;
$('#gbox_my-grid').replaceWith(grid);
grid.jqGrid(options);

, <table>. , jqGrid.

jQuery DataTables , jqGrid.

0

reloadGrid , .

colNames colModel , . GridUnload, ( grid.jqGrid(data) ). , jQuery grid , grid GridUnload, - grid = $("#grid"); GridUnload.

. .

+5

, .

var grid = $('#tableID');

if(grid[0].grid == undefined) {
  grid.jqGrid(options);
} else {
  delete grid;
  $('#tableID').GridUnload('#tableID');
  $('#tableID').jqGrid(options);
}
+1

All Articles