I have a jqgrid which is not inside document.ready. It will be triggered only when I click a button.
function getData{
DataHandler.getTasks(locName,{callback:function(data){
jQuery("#TaskTable").jqGrid(
{
datatype : "local",
data : resultSet,
height : 250,
width : 960,
sortable : false,
ignoreCase : true,
sortorder : "desc",
//rest of the table contents like colname and colmodel
});
}, errorHandler:function(){
},async:false
});
I would like to clear the grid on every button click so as to remove the data already present and reload. Any help in doing this? Where should I give the clear grid inside document ready or on button click?
Thanks
Assuming the markup of:
<table id='myGrid' />
You can clear and load fresh data from the server by using the following code:
function loadTable() {
$('#myGrid').jqGrid('GridUnload'); //this does the work of clearing out the table content and loading fresh data
$('myGrid').jqGrid({
url: 'url goes here',
dataType: 'json',
jsonReader: {
root: 'Data',
page: 'CurrentPage',
total: 'TotalPage',
records: 'TotalRecords',
repeatitems: false
},
onSelectRow: editRow
});
}
You can also check the following link for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With