jqGrid GridUnload/GridDestroy

jqGrid GridUnload/ GridDestroy(jqGrid GridUnload/GridDestroy)

本文介绍了jqGrid GridUnload/GridDestroy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 $('#mygrid').jqGrid('GridUnload'); 我的网格被破坏:没有寻呼机/没有标题.

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

在我发现的一个 wiki 中:

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.

我找不到 GridUnload/GridDestroy 之间的任何区别,还是我有什么问题?

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

我使用 jqGrid 3.8.

推荐答案

为了能够在页面上创建 jqGrid,你必须在页面的位置插入一个空的 <table> 元素你想在哪里看到网格.最简单的表格元素示例是 <table id="mygrid"></table>.

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>.

在您调用 $('#mygrid').jqGrid({...}) 并且将创建列标题等网格元素.

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.

GridDestroy 方法的工作方式类似于 jQuery.remove.它删除所有属于网格的元素包含 <table>元素.

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

另一方面,GridUnload 方法删除所有内容,但

元素保留在页面上.所以你可以在同一个地方创建新的网格.如果您需要根据不同的条件在一个地方创建不同的网格,则 GridUnload 方法非常有用.查看 旧答案 与 演示.该演示展示了如何在同一个地方动态创建两个不同的网格.如果您只是将代码中的 GridUnload 替换为 GridDestroy,则演示将不起作用:在销毁第一个网格后,将不会在同一位置创建其他网格.

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.

这篇关于jqGrid GridUnload/GridDestroy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:jqGrid GridUnload/GridDestroy

基础教程推荐