سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top