Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid GridUnload/ GridDestroy

Tags:

When I use $('#mygrid').jqGrid('GridUnload'); my grid is destroyed: no pager/ no header.

In a wiki I found:

The only difference to previous method is that the grid is destroyed, but the table element and pager (if any) are left ready to be used again.

I can't find any difference between GridUnload/ GridDestroy or do I something wrong?

I use jqGrid 3.8.

like image 542
Scharlotte Avatar asked Feb 07 '11 10:02

Scharlotte


People also ask

What is GridUnload?

It deletes all elements which belong to the grid inclusve the <table> element. The method GridUnload on the other hand delete all, but the empty <table> element stay on the page. So you are able to create new grid on the same place.

What is the use of jqGrid?

Free jqGrid is a JavaScript plugin that displays table-based data in a lot of different configurations. The data can be loaded from JavaScript array or be loaded from the server (in JSON or XML format). It supports client-side paging, sorting and filtering on server-side.

How do you hide jqGrid?

Just set opacity:0 for jqgrid element. it will work also.


1 Answers

To be able to create jqGrid on the page you have to insert an empty <table> element on the place of the page where you want see the grid. The simplest example of the table element is <table id="mygrid"></table>.

The empty <table> element itself will be not seen on the page till you call $('#mygrid').jqGrid({...}) and the grid elements like column headers will be created.

The method GridDestroy works like jQuery.remove. It deletes all elements which belong to the grid inclusve the <table> element.

The method GridUnload on the other hand delete all, but the empty <table> element stay on the page. So you are able to create new grid on the same place. The method GridUnload is very usefull if you need create on one place different grids depend on different conditions. Look at the old answer with the demo. The demo shows how two different grids can by dynamically created on the same place. If you would be just replace GridUnload in the code to GridDestroy the demo will be not work: after destroying of the first grid no other grids will be created on the same place.

like image 143
Oleg Avatar answered Sep 19 '22 12:09

Oleg