jqGrid reload grid(jqGrid 重新加载网格)
                            本文介绍了jqGrid 重新加载网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
                        
                        问题描述
这是我之前关于将列添加到基于 jqGrid 的表中的问题的补充.这是我的新js代码:
It's an addition for previous my question about adding columns into jqGrid-based table. Here my new js-code:
var col_names = ['First', 'Second', 'Third', 'Fourth', 'Fifth'];
var col_model = [
      {name:'invid', index:'invid', width:100}, 
      {name:'invdate', index:'invdate', width:90}, 
      {name:'amount', index:'amount', width:80, align:'right'}, 
      {name:'tax', index:'tax', width:80, align:'right'}, 
      {name:'total', index:'total', width:80, align:'right'}, 
];
function createGrid()
{
  var handle = $("#list").jqGrid({
    url:'data.xml',
    datatype: 'xml',
    mtype: 'GET',
    colNames: col_names,
    colModel : col_model,
  }); 
}
现在我在加载文档后调用 createGrid(); ,一切正常.现在我想添加一个新列(带有空数据)并重新加载 jqGrid:
Now I call createGrid(); after document is loaded, everything works fine. Now I want to add a new column (with empty data) and reload jqGrid:
  $("#add_column").click(function() {
        $('#list').trigger("DestroyGrid"); // Also tried UnloadGrid
        col_names.push('New');
        col_model.push({name: 'test', index: 'test', width: 100});
        createGrid(); // And recreate grid
  });
但是什么都没有发生,为什么?
But nothing happens, why?
UPD
  $("#add_column").click(function() {
        col_names.push('New');
        col_model.push({name: 'test', index: 'test', width: 100});
        $('#list').trigger("reloadGrid");
  });
同样的情况
UPD2我试过这些:
ajaxGridOptions: {cache: false},
loadonce:false
没有改变现状.
推荐答案
你可以做以下事情
var counter=1; // to be able to click more then one time
$("#add_column").click(function() {
    $("#list").jqGrid('GridUnload');
    col_names.push('New'+counter);
    col_model.push({name: 'test'+counter, index: 'test'+counter, width: 100});
    counter++;
    createGrid();
});
                        这篇关于jqGrid 重新加载网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
				 沃梦达教程
				
			本文标题为:jqGrid 重新加载网格
				
        
 
            
        基础教程推荐
             猜你喜欢
        
	     - 如何在特定日期之前获取消息? 2022-01-01
 - 什么是不使用 jQuery 的经验技术原因? 2022-01-01
 - 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
 - Node.js 有没有好的索引/搜索引擎? 2022-01-01
 - 每次设置弹出窗口的焦点 2022-01-01
 - Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
 - 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
 - jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
 - 如何使用 CSS 显示和隐藏 div? 2022-01-01
 - WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				