Is there a way to restore some of the functionality of the previous version of the jqGrid?
Asked Answered
P

1

0

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. In the previous version, we could add a new filter by selecting a plus button next to an existing filter. Using this + button would cause the newly created filter to have the same options as the existing filter.

Old Search

New Search

  1. In the previous version, I could not delete all of the filters from the search box. Clicking remove when only one filter was in the box did nothing. I need a way to prevent users from zapping out the last filter control.

All filters deleted

Precaution answered 12/4, 2012 at 19:21 Comment(1)
I suppose you mean updated our jqGrid from 3.8.2 to 4.3.2. The version 4.3.2 was recently published. Additionally you asked two separate questions in one. It makes difficult for other users to find the information. It's better to separate the current questions in two.Minni
M
4

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.

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.

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:

enter image description here

About your second question:

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.

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();
    }
});

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();
        }
    }
});
Minni answered 12/4, 2012 at 20:49 Comment(3)
@tpeczek: Thanks! By the way I posted recently two pool requests (this and this) which improves functionality of jqGrid. The first one are already merged in jqGrid. The demo shows how one can use now custom controls in searching dialog ("Ranking" field). Another demo shows keyboard (searchOnEnter, closeOnEscape and holding the focus on button clicks) support and jQuery UI Button style.Minni
@tpeczek: I try to improve quality of language files included in jqGrid. I posted just now the post. If you find time, could you write you comments about the issues which I found in grid.locale-pl.js?Minni
Sure, I will look at this later todayAre

© 2022 - 2024 — McMap. All rights reserved.