Question

I want make jqgrid in dynamic. so i have one variable in which i.e.

<script type="text/javascript">
$('#ok').click(function(){
    var Str='jQuery("#list").jqGrid({ url:'server.php', datatype: "json", colNames:['...'], colModel:[ {...}], rowNum:10, rowList:[10,20,30], pager: '#pager2', sortname: 'id', viewrecords: true, sortorder: "desc", caption:"JSON Example" });'
});
</script>
<html>
<table id="list"></table>
<div id="pager"></div>
</html>

How send Request of jqgrid?

Was it helpful?

Solution

You can manually force a reload of the grid by:

jQuery('#list').jqGrid().trigger('reloadGrid', [{ page: 1}]);

In fact may I suggest that you fully build the grid on the load of the page, with the datatype set to datatype: local and then on your click event you can just

jQuery('#list_container').show();
jQuery('#list').jqGrid('setGridParam', { datatype: 'json', url: '/server.php' }).trigger('reloadGrid', [{ page: 1}]);

This way you jqGrid is sitting there, hidden and waiting to be loaded when you click. If the datatype is set to local it will not attempt to load any information till you click.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top