destroy Returns: void


Destroy the grid. This method remove all data from the grid and all events attached to the grid.

The grid table tag and wrapper tag are kept by default after the execution of destroy method,but you can remove them if you pass false to the keepTableTag and keepWrapperTag parameters.

Fires

destroying

Parameters

NameTypeDescription
keepTableTag {bool} If this flag is set to false, then the table tag will be removed from the HTML dom tree.
keepWrapperTag {bool} If this flag is set to false, then the table wrapper tag will be removed from the HTML dom tree.

Examples

  
Edit this example
<button id="btnDestroy">Destroy</button> <button id="btnCreate">Create</button> <br/><br/> <table id="grid"></table> <script> var grid, createFunc; createFunc = function() { grid = $("#grid").grid({ dataSource: "../Grid/GetPlayers", columns: [ { field: "ID" }, { field: "Name" }, { field: "PlaceOfBirth" } ] }); }; createFunc(); $("#btnDestroy").on("click", function () { grid.destroy(true, true); }); $("#btnCreate").on("click", function () { createFunc(); }); </script>
  
Edit this example
<button id="btnRemove">Remove</button> <br/><br/> <table id="grid"></table> <script> var grid = $("#grid").grid({ dataSource: "../Grid/GetPlayers", columns: [ { field: "ID" }, { field: "Name" }, { field: "PlaceOfBirth" } ] }); $("#btnRemove").on("click", function () { grid.destroy(); }); </script>