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
destroyingParameters
Name | Type | Description |
---|---|---|
keepTableTag | {bool} | If this flag is set to false, the table tag will be removed from the HTML dom tree. |
keepWrapperTag | {bool} | If this flag is set to false, the table wrapper tag will be removed from the HTML dom tree. |
Examples
keep wrapper and table
<button id="btnDestroy">Destroy</button>
<button id="btnCreate">Create</button>
<br/><br/>
<table id="grid"></table>
<script>
var createFunc = function() {
$('#grid').grid({
dataSource: '/0_6/Grid/GetPlayers',
columns: [ { field: 'ID' }, { field: 'Name' }, { field: 'PlaceOfBirth' } ]
});
};
createFunc();
$('#btnDestroy').on('click', function () {
$('#grid').grid('destroy', true, true);
});
$('#btnCreate').on('click', function () {
createFunc();
});
</script>
remove wrapper and table
<button id="btnRemove">Remove</button>
<br/><br/>
<table id="grid"></table>
<script>
var grid = $('#grid').grid({
dataSource: '/0_6/Grid/GetPlayers',
columns: [ { field: 'ID' }, { field: 'Name' }, { field: 'PlaceOfBirth' } ]
});
$('#btnRemove').on('click', function () {
grid.destroy();
});
</script>