Consecutive GridUnload createGrid not working

萝らか妹 提交于 2020-01-24 12:58:06

问题


Any ideas why multiple calls to a function that does the following

grid.jqGrid('GridUnload');
createGrid();

Will only create the grid every other time, but ...

The following will work everytime it is called:

grid.jqGrid('GridUnload');
setTimeout(createGrid, 1000);

回答1:


You don't included the code of createGrid so I can only guess. One possible reason is that you use grid variable inside. If you use GridUnload the old <table> element will be deleted and another one will be created on the same place. So you should reset the value of grid after call of GridUnload:

var gridId = grid[0].id; // or grid.attr('id');
grid.jqGrid('GridUnload');
grid = $('#' + $.jgrid.jqID(gridId)); // or just $('#' + gridId);
createGrid();

The method $.jgrid.jqID you have to use only if the id of the grid can hold some meta-character.



来源:https://stackoverflow.com/questions/9472409/consecutive-gridunload-creategrid-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!