有没有办法恢复jqGrid先前版本的某些功能? [英] Is there a way to restore some of the functionality of the previous version of the jqGrid?

查看:78
本文介绍了有没有办法恢复jqGrid先前版本的某些功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近将jqgrid从3.8.2更新到4.3.1,因为我们希望能够使用搜索模板,并确保我们拥有所有可用的错误修复程序.但是,有两件事已经发生了变化,我想看看是否可以使新版本的行为像以前的版本一样.

We recently updated our jqgrid from 3.8.2 to 4.3.1 because we wanted to be able to use the search templates and also to make sure we had all available bug fixes. But, there are two things that have changed that I'd like to see if I can make the new version behave like the previous version.

我们使用了高级搜索,并且已将我们的网站配置为始终在网格上方显示固定的搜索对话框.

We used advanced searching, and have our site configured to always show the search dialog fixed above the grid.

  1. 在以前的版本中,我们可以通过选择现有过滤器旁边的加号按钮来添加新的过滤器.使用此+按钮将使新创建的过滤器具有与现有过滤器相同的选项.

  1. 在以前的版本中,我无法从搜索框中删除所有过滤器.当框中只有一个过滤器时,单击删除"不会执行任何操作.我需要一种方法来防止用户更改最后一个过滤器控件.

推荐答案

您一起发布了两个独立的问题.其他用户很难找到该信息.最好将当前问题一分为二.

You posted two separate questions together. It makes difficult for other users to find the information. It's better to separate the current questions in two.

不过,关于您问题的第一部分,我只想描述一下,由于使用 jQuery.clone .该功能有很多错误,很长一段时间以来一直没有修复.因此,搜索对话框"在某些情况下会出错.在搜索对话框"的新实现中,没有明确使用 jQuery.clone 作为唯一安全的方法解决问题的方法. 默认情况下实现了您在新版本的搜索对话框"中错过的行为.在新的搜索对话框"中,相应的代码不存在,但您可以自己编写.通常,您需要在 afterRedraw 回调.

Nevertheless, about the first part of your question I want just describe that the behavior of the old Searching Dialog was so because of the usage of jQuery.clone. The function had many bugs which was not fixed since a long time. So the Searching Dialog worked wrong in some situations. In the new implementation of the Searching Dialog one didn't used jQuery.clone explicitly as the only safe way to solve the problems. The behavior which you miss in the new version of the Searching Dialog was by default implemented. In the new Searching Dialog the corresponding code isn't exist, but you can write it yourself. Mostly what you need is to write your custom code in the afterRedraw callback.

您应该考虑到jqGrid现在支持功能强大的multipleGroup: true选项.因此,您可能需要复制来自同一组的另一个控件 的选择:

You should take in consideration that jqGrid support now powerful multipleGroup: true option. So what you need is probably to copy the selections from another controls of the same group:

关于第二个问题:

答案包含

The answer contains the demo which describe the idea to unbind the click. Probably event better would be to unbind or to hide the "Delete rule" button only if it is the only button.

如果您不使用multipleGroup: true选项,则可以尝试以下操作

If you don't use multipleGroup: true option you can try the following

$.extend($.jgrid.search, {
    multipleSearch: true,
    overlay: 0,
    afterRedraw: function () {
        // don't permit to remove the last rule
        $('input.delete-rule:first',this).unbind('click').hide();
    }
});

在使用multipleGroup: true的情况下,最好使用其他代码

In case of usage multipleGroup: true the better will be probably another code

$.extend($.jgrid.search, {
    multipleSearch: true,
    multipleGroup: true,
    overlay: 0,
    afterRedraw: function () {
        // don't permit to remove the last rule
        var $delRules = $('input.delete-rule', this);
        if ($delRules.length === 1) {
            $delRules.unbind('click').hide();
        }
    }
});

这篇关于有没有办法恢复jqGrid先前版本的某些功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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