I'm using jqGrid and I have a problem with refresh data after call event of jstree.
I'm following in this post. Exactly I don't know where to put it.
This is my code. What shoud I do?
$('#jsTree_DonVi').on('changed.jstree', function (e, data) {
var id = data.instance.get_node(data.selected[0]).id;
var text = data.instance.get_node(data.selected[0]).text;
var tinhTrang = 0;
var nam = 0;
// I tried but it's not working
$("#jqGrid").setGridParam({ datatype: 'json' });
$("#jqGrid").trigger("reloadGrid");
//---
$("#jqGrid").jqGrid({
url: '/Home/GetData',
postData: {
"id": id,
"nam": nam,
"tinhTrang": tinhTrang
},
datatype: "json",
colModel: [
{
label: 'Tên công trình', name: 'Ten', sorttype: 'string', width: 800, align: 'center'
},
{ label: 'Kế hoạch/Thực hiện', name: 'KHTH', sorttype: 'string', align: 'center' },
{ label: 'Địa điểm xây dựng', name: 'DiaDiem', sorttype: 'string', align: 'center' }
],
viewrecords: true, // show the current page, data rang and total records on the toolbar
rowNum: 30,
width: 1228,
height: 500,
loadonce: true,
pager: "#jqGridPager"
})};
My HTML:
<div id="renderTable">
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
</div>
Solution here:
I changed my jqGrid from Guriddo jqGrid JS to Free jqGrid.
And replace
$("#jqGrid").setGridParam({ datatype: 'json' });
$("#jqGrid").trigger("reloadGrid");
To
$("#jqGrid").jqGrid('GridUnload');