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

  • Home
  • SEARCH
  • 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 6719167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:03:38+00:00 2026-05-26T09:03:38+00:00

jqgrid edit and add forms coontain textareas which can edited and enter adds new

  • 0

jqgrid edit and add forms coontain textareas which can edited and enter adds new line to them.

How to allow Ctrl+S to save edit and add forms, just like clicking to save button in those forms ?

For inline edit I was able to add Save button to jqgrid toolbar and use

    case 83: $("#grid_savebutton").click(); break;

In body onkeydown event to simulate pressing to this button by Ctrl+S

How to allow also to save in edit and add forms by Ctrl+S ?

Update

I added code

        case 83: saveb = $("#TblGrid_" + "grid"+ "_2 #sData");
            if (saveb.length > 0 ) {
                   evt.stopPropagation();
                   return;
                  }
            $("#grid_savebutton").click(); 
            break;

to body onkeydown handler. After first edit form open this code finds always that sData button exists and goes not invoke grid_savebutton anymore. It looks like sData button exists even if edit/add form is closed.
How to fix it so that if edit/add form is not open, $(“#grid_savebutton”).click() is executed ?

Update2

keydown bindings used:

            jQuery.extend(jQuery.jgrid.edit, {
               savekey: [true, 13],
               recreateForm: true,
               closeOnEscape: true,
               reloadAfterSubmit: false,
               beforeShowForm: function ($form) {
                 var gridIdEncoded = $.jgrid.jqID($form[0].id.substring(8));
                 $("#editmod" + gridIdEncoded).bind( 'keydown', beforeShowFormHandler);
                  },

               onClose: function () {
                 var gridIdEncoded = 'grid'; // $.jgrid.jqID($form[0].id.substring(8));
                 $("#editmod" + gridIdEncoded).unbind( 'keydown', beforeShowFormHandler);
                  }
            });


    var beforeShowFormHandler = function (e) {
        var gridIdEncoded = 'grid';
        if (e.ctrlKey && e.which === 83) { // 83 - 's'
          $("#TblGrid_" + gridIdEncoded + "_2 #sData").trigger("click");
          return false;
          }
    };

global keydown binding:

$(function () {
    $("html").keydown(body_onkeydown);
});


function body_onkeydown(evt) {
    var saveb;
    if (evt.ctrlKey) {
        switch (evt.keyCode) {
            case 83: 
              saveb = $("#TblGrid_" + "grid" + "_2 #sData");
                // todo: saveb.length > 0 is always true after form is opened first time: 
                if (saveb.length > 0) return;
                $("#grid_savebutton").click(); break;
               }
        cancel(evt);
        return false;
    }
}

function cancel(evt) {
    evt.returnValue = false;
    evt.keyCode = 0;
    evt.cancelBubble = true;
    evt.preventDefault();
    evt.stopPropagation();
}

Update3

TinyMCE html editor is attached to textarea elemnts in form in afterShowForm event using

    $('.htmleditor', formSelector).attr('cols', '50').attr('rows', '15').tinymce({
        theme: "advanced",
        language: "et",
        theme_advanced_buttons2: "",
        theme_advanced_buttons3: "",
        theme_advanced_buttons1: "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter," +
"justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,|,cut ,copy,paste,undo,redo" +
"link,unlink,image,cleanup,code,hr,|,removeformat,formatselect,|,fontselect,fontsizeselect," +
"sub,sup,|,forecolor,backcolor,forecolorpicker,backcolorpicker,charmap,visualaid," +
"anchor,blockquote"
    });
}

Ctrl+S in textarea causes IE9 standard save dialog to appear in this case. How to allow Ctrl+S to save form in tinyMCE also ?

  • 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-05-26T09:03:38+00:00Added an answer on May 26, 2026 at 9:03 am

    You can register an additional keydown event handler inside of beforeShowForm. The code can be like the following:

    beforeShowForm: function ($form) {
        // $form[0].id is like "FrmGrid_list"
        var gridIdEncoded = $.jgrid.jqID($form[0].id.substring(8));
        $("#editmod" + gridIdEncoded).keydown(function (e) {
            if (e.ctrlKey && e.which === 83) { // 83 - 's'
                $("#TblGrid_" + gridIdEncoded + "_2 #sData").trigger("click");
                return false; // stop propagation
            }
        });
    }
    

    You can see live demo here. Because I use local editing without setting any editurl you see an error message on pressing Ctrl + S in the edit form. It means that submiting will be fire, but not successful.

    UPDATED: Look at the demo. On pressing Ctrl + S it displays alert "Ctrl-S in body" if the edit form is close and try to submit the form if the edit form is opened. Is it not what you need? In the code (see below) I used keydown from the formEvent namespace (just a free name)

    $("#list").jqGrid ('navGrid', '#pager',
        {add: false, del: false, refresh: true, view: false},
        {beforeShowForm: function ($form) {
            // $form[0].id is like "FrmGrid_list"
            var gridIdEncoded = $.jgrid.jqID($form[0].id.substring(8));
            $("#editmod" + gridIdEncoded).bind('keydown.formEvent', function (e) {
                if (e.ctrlKey && e.which === 83) { // 83 - 's'
                    $("#TblGrid_" + gridIdEncoded + "_2 #sData").trigger("click");
                    return false;
                }
            });
        },
        onClose: function (formselector) {
            $(formselector).unbind('keydown.formEvent');
        }}, {}, {}, {multipleSearch: true, overlay: false});
    
    $("html").keydown(function (e) {
        if (e.ctrlKey && e.which === 83) { // 83 - 's'
            alert("Ctrl-S in body");
            return false;
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

jqGrid edit and add forms render every field in separate row. If there are
jqGrid add forms contains autocomplete boxes using code below. If new row is added
I have a jqGrid that has add/edit dialogs with a form that's longer than
I have jqGrid with enabled EDIT, DELETE, ADD and VIEW , Now my problem
I want to display a combobox with add/edit dialog on Jqgrid. I could do
how can I set the width and height of edit/add panel that appear if
I have a jqGrid with say user information which is to be edited in
i m using jqgrid with mvc 3, I want to add Edit and Delete
I have a jqGrid on a page and users can click a button to
I have a jqGrid with which users will select records. A large number of

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.