保存或编辑后,JqGrid不会刷新记录 [英] After Save or Edit JqGrid doesn't refresh the records

查看:412
本文介绍了保存或编辑后,JqGrid不会刷新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JqGrid列出,添加,删除,编辑,查找我的记录.当我选择loadonce = false时,通常会在del,edit或add之后刷新记录.但是,分页和搜索mechanisim无效.一旦我选择loadonce = true,它将在删除后刷新记录,而不是在添加或编辑后刷新记录.然后,分页和搜索将以loadonce = true模式正常运行.我尝试过了

Im using JqGrid to list, add, delete, edit, find the my records. When i choose the loadonce=false, it normally refresh the records after del, edit or add. But, paging and searching mechanisim doesnt works. Once i choose the loadonce=true, it refresh the records after delete, not after add or edit. And then paging and searching runs normally in loadonce=true mode. i tried the;

$("#list").setGridParam({datatype:'json', page:1}).trigger('reloadGrid');

afterInsertRow: function (rowid,rowdata,rowelem){
    alert("hello"); // this wasnt invoked
}

但是他们没有解决我的问题.

but they didnt solve my problem.

我的问题是什么原因

推荐答案

如果使用loadonce: false,则必须在服务器端实现分页,排序和搜索.如果分页和搜索不起作用,则您没有在当前服务器代码中实现这些功能.

If you use loadonce: false than you have to implement paging, sorting and searching on the server side. If paging and searching are not working, then you don't implemented the features in your current server code.

选项reloadAfterSubmit指定是否在编辑后重新加载网格.

The option reloadAfterSubmit specify whether the grid will be reloaded after editing.

如果使用loadonce: true,则第一次加载后,datatype将更改为'local'.问题在于jqGrid不支持本地表单编辑.因此,您必须为添加/编辑/删除实现服务器部分.问题在于,这种情况下的重新加载将本地执行,而不是从服务器执行.要在表单编辑结束后从服务器重新加载数据,您可以将datatype重置为afterSubmit回调内部的初始状态("json"或"xml").在这种情况下,下一次重新加载(对于reloadAfterSubmit: true)将根据需要从服务器进行.

If you use loadonce: true the datatype will be changed to 'local' after the first load. The problem is that jqGrid don't support local form editing. So you have to implement the server part for Add/Edit/delete. The problem is that reloading in the case will be executed local and not from the server. To reload the data from the server after end of form editing you can reset the datatype to the initial state ('json' or 'xml') inside of afterSubmit callback. In the case the next reloading (in case of reloadAfterSubmit: true) will be done from the server like you as want.

已更新:以下代码提交后应该可以解决问题:

UPDATED: The following code of afterSubmit should solve the problem:

afterSubmit: function () {
    $(this).jqGrid("setGridParam", {datatype: 'json'});
    return [true];
}

这篇关于保存或编辑后,JqGrid不会刷新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆