Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:04:47+00:00 2026-06-01T12:04:47+00:00

Answer in how to enable enter in jqgrid advanced search window describes how to

  • 0

Answer in how to enable enter in jqgrid advanced search window describes how to enable enter and other keys in jqgrid advanced search dialog.

After clicking Add group, Add subgrup, Delete rule or Delete group button in advanced search dialog Enter and other keys are still ignored. How set focus to added element or after delete remaining element to enable Enter and other keys?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:04:47+00:00Added an answer on June 1, 2026 at 12:04 pm

    The current version of the Advanced Searching dialog (see definition of jqFilter in the grid.filter.js) recreate all controls of the dialog on change of someone. See the code of reDraw which looks

    this.reDraw = function() {
        $("table.group:first",this).remove();
        var t = this.createTableForGroup(p.filter, null);
        $(this).append(t);
        if($.isFunction(this.p.afterRedraw) ) {
            this.p.afterRedraw.call(this, this.p);
        }
    };
    

    How one can see the first line $("table.group:first",this).remove(); delete the content of all filter. The current focus will be lost and one have the problems which you described.

    I suggest to fix the code of reDraw using document.activeElement element which was introduced in Internet Explorer originally (at least in IE4) and which is supported now in all web browsers because it’s part of HTML5 standard (see here). The element which has focus originally will be destroyed and one will unable to set focus on it later. So I suggest to save the element name of the element and it’s classes (like input.add-group or input.add-rule.ui-add) and to find the position of the element on the searching dialog. Later, after the dialog element will be recreated we’ll set focus on the element with the same index.

    I suggest to change the code of reDraw to the following

    this.reDraw = function() {
        var activeElement = document.activeElement, selector, $dialog, activeIndex = -1, $newElem, $buttons,
            buttonClass,
            getButtonClass = function (classNames) {
                var arClasses = ['add-group', 'add-rule', 'delete-group', 'delete-rule'], i, n, className;
                for (i = 0, n = classNames.length; i < n; i++) {
                    className = classNames[i];
                    if ($.inArray(className, arClasses) >= 0) {
                        return className;
                    }
                }
                return null;
            };
        if (activeElement) {
            selector = activeElement.nodeName.toLowerCase();
            buttonClass = getButtonClass(activeElement.className.split(' '));
            if (buttonClass !== null) {
                selector += '.' + buttonClass;
                if (selector === "input.delete-rule") {
                    $buttons = $(activeElement).closest('table.group')
                        .find('input.add-rule,input.delete-rule');
                    activeIndex = $buttons.index(activeElement);
                    if (activeIndex > 0) {
                        // find the previous "add-rule" button
                        while (activeIndex--) {
                            $newElem = $($buttons[activeIndex]);
                            if ($newElem.hasClass("add-rule")) {
                                activeElement = $newElem[0];
                                selector = activeElement.nodeName.toLowerCase() + "." +
                                    getButtonClass(activeElement.className.split(' '));
                                break;
                            }
                        }
                    }
                } else if (selector === "input.delete-group") {
                    // change focus to "Add Rule" of the parent group
                    $newElem = $(activeElement).closest('table.group')
                        .parent()
                        .closest('table.group')
                        .find('input.add-rule');
                    if ($newElem.length > 1) {
                        activeElement = $newElem[$newElem.length-2];
                        selector = activeElement.nodeName.toLowerCase() + "." +
                            getButtonClass(activeElement.className.split(' '));
                    }
                }
                $dialog = $(activeElement).closest(".ui-jqdialog");
                activeIndex = $dialog.find(selector).index(activeElement);
            }
        }
        $("table.group:first",this).remove();
        $(this).append(this.createTableForGroup(this.p.filter, null));
        if($.isFunction(this.p.afterRedraw) ) {
            this.p.afterRedraw.call(this, this.p);
        }
        if (activeElement && activeIndex >=0) {
            $newElem = $dialog.find(selector + ":eq(" + activeIndex + ")");
            if ($newElem.length>0) {
                $newElem.focus();
            } else {
                $dialog.find("input.add-rule:first").focus();
            }
        }
    };
    

    Like one can see on the next demo the focus in the Searching Dialog stay unchanged after pressing on the “Add subgroup” or “Add rule” buttons. I set it on the “Add rule” buttons of the previous row group in case of pressing “Delete group”.

    One more demo use jQuery UI style of the buttons and the texts in the buttons (see the answer). After clicking on the “Delete” (rule or group) button I tried to set the focus to the previous “Add Rule” button because setting of the focus on another “Delete” (rule or group) button I find dangerous.

    Additionally in the demo I use

    afterShowSearch: function ($form) {
        var $lastInput = $form.find(".input-elm:last");
        if ($lastInput.length > 0) {
            $lastInput.focus();
        }
    }
    

    because it seems me meaningful to set initial focus on the last input field at the dialog opening.

    UPDATED: I find additionally meaningful to set focus on the current clicked buttons “Add subgroup”, “Add rule” or “Delete group”. The advantage one sees in the case it one first click some button with the mouse and then want to continue the work with keyboard. So I suggest to change the line

    inputAddSubgroup.bind('click',function() {
    

    to

    inputAddSubgroup.bind('click',function(e) {
        $(e.target).focus();
    

    To change the line

    inputAddRule.bind('click',function() {
    

    to

    inputAddRule.bind('click',function(e) {
        $(e.target).focus();
    

    and the line

    inputDeleteGroup.bind('click',function() {
    

    to

    inputDeleteGroup.bind('click',function(e) {
        $(e.target).focus();
    

    and the line

    ruleDeleteInput.bind('click',function() {
    

    to

    ruleDeleteInput.bind('click',function(e) {
        $(e.target).focus();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got answer from the SDL Tridion forum that we can enable inline editing
I'm writing a small webpage that will enable students to answer questions and get
After viewing answer of almost a same question on SO i added this line
Answer : Implemented using Curl... $file = http://abc.com/data//output.txt; $ch = curl_init($file); $fp = @fopen(out.txt,
Answer solved in edit below I had this piece of code Dictionary<Merchant, int> remaingCards
ANSWER: You cannot write an int directly to a file. Convert it to a
This answer says: Vim's undo/redo system is unbeatable. Type something, undo, type something else,
The answer to What is the correct way to make exceptions serializable? says that
The answer to this question: Declarative Security--what's this? Doesn't really tell me much... doesn't
enum Answer : int { Yes = 1, No = 2 } Answer answer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.