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 6895243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:53:02+00:00 2026-05-27T06:53:02+00:00

Code below from other stackoverflow answer is used in jqGrid to implement checkbox using

  • 0

Code below from other stackoverflow answer is used in jqGrid to implement checkbox using jquery UI in jqGrid top toolbar. This is used to toggle autoedit variable true – false states.

Checkbox caption is too wide for toolbar. How to change checkbox to toolbar button with two states which reflect autoedit true/false values (checked and unchecked states). Instead of check mark similar button should appear in pressed or checked state and in regular/unchecked state if clicked again.
Pure checkmark without caption cannot used since there should be some visual glue instead of checkbox rectangle if tolbar contains more than one such checkbox to distinguish them visually.

var autoedit=false;       
$("#grid_toppager_left table.navtable tbody tr").append(
    '<td><div><label><input class="ui-pg-div" tabindex="-1" type="checkbox" ' +
        (autoedit ? 'checked ' : '') +
        'id="AutoEdit" />Checbox caption which should appear as top toolbar button tooltip' +
        '</label></div></td>');
$("#AutoEdit").change(function () {
    if ($(this).is(':checked')) {
        autoedit = true;
        $("#AutoEdit").attr("checked", "checked");
    } else {
        autoedit = false;
        $("#AutoEdit").removeAttr("checked");
    }
});
  • 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-27T06:53:02+00:00Added an answer on May 27, 2026 at 6:53 am

    I find your question very interesting. So I made some demos which shows how to implement “toggle” buttons in the navigator bar of jqGrid. In all demos I used top toolbar.

    I decide to use jQuery UI Button widget. It allows different kind of buttons one from there, the “toggle” button we need. The buttons can be just a text, just an icon or be combination of the text and up to two icons (one icon before the text and another after the text). As the result one can create toolbars like the following:

    enter image description here and enter image description here in the “checked” state,

    enter image description here and enter image description here in the “checked” state,

    enter image description here and enter image description here in the “checked” state,

    or just icons only like enter image description here and enter image description here for the “checked” state.

    Because I used the top toolbar I For the implementation I applied the path of some jqGrid CSS which I described here:

    .ui-jqgrid .ui-jqgrid-toppager .ui-pg-div {
        padding: 1px 0;
        float: left;
        position: relative;
    }
    .ui-jqgrid .ui-jqgrid-toppager .ui-pg-button {
        height: 18px !important;
        cursor: pointer;
    }
    .ui-jqgrid .ui-jqgrid-toppager .ui-pg-div span.ui-icon {
        float: left;
        margin: 0 2px;
    }
    

    The code which add the custom button which you posted I would modified to

    var autoedit=false;
    ...
    $("#grid_toppager_left table.navtable tbody tr").append(
        '<td class="ui-pg-button ui-corner-all">' +
            '<div class="ui-pg-div my-nav-checkbox">' +
            '<input tabindex="-1" type="checkbox" id="AutoEdit" />' +
            '<label title="Checkx caption which should appear as button tooltip"' +
            ' for="AutoEdit">Autoedit</label></div></td>'
    );
    $("#AutoEdit").button().click(function () {
        if ($(this).is(':checked')) {
            autoedit = true;
            alert("Autoedit mode is ON");
        } else {
            autoedit = false;
            alert("Autoedit mode is OFF");
        }
    });
    

    in case of pure text button with the text “Autoedit”. The corresponding additional CSS settings can be

    /* some settings to place Button in jqGrid */
    .ui-jqgrid .ui-pg-table .my-nav-checkbox {
        margin: 0px;
        padding: 0px;
        float: left;
        height: 18px
    }
    /* fixing CSS of jQuery UI Buttons */
    .ui-jqgrid .ui-pg-table .my-nav-checkbox > .ui-button > span.ui-button-text {
        margin: 0px;
        padding: 1px 2px 1px 2px;
    }
    

    In case of usage the icon with the text the code will be

    $("#AutoEdit").button({
        icons: {primary: "ui-icon-mail-closed"}
    }).click(function () {
        var iconClass;
        if ($(this).is(':checked')) {
            autoedit = true;
            iconClass = "ui-icon-mail-open";
        } else {
            autoedit = false;
            iconClass = "ui-icon-mail-closed";
        }
        $(this).button("option", {icons: {primary: iconClass}});
    });
    

    To make the button with icon only without the text one need just add text: false option in the list of .button({...}) parameters

    $("#AutoEdit").button({
        text: false,
        icons: {primary: "ui-icon-mail-closed"}
    }).click(function () {
    ...
    

    In both cases the following CSS can be used

    /* some settings to place Button in jqGrid */
    .ui-jqgrid .ui-pg-table .my-nav-checkbox {
        margin: 0px;
        padding: 0px;
        float: left;
        height: 18px
    }
    .ui-jqgrid .ui-pg-table .my-nav-checkbox > input {
        padding: 1px;
    }
    .ui-jqgrid .ui-pg-table .my-nav-checkbox > label {
        margin: 0px;
    }
    /* fixing CSS of jQuery UI Buttons */
    .ui-jqgrid .ui-pg-table .my-nav-checkbox > .ui-button > span.ui-button-text {
        margin: 0px;
        padding: 1px 2px 1px 16px;
    }
    .ui-button-icon-only {
        width: 16px;
    }
    .ui-jqgrid .ui-pg-table .my-nav-checkbox > .ui-button > span.ui-button-icon-primary {
        margin: -8px 0px 0px -8px;
    }
    

    For different demos you can find here:

    • icon only “toggle” button
    • text only “toggle” button
    • “toggle” button with the icon and the text
    • “toggle” button with the text and two icons

    To have the border over the button only on hovering you can change the CSS for the .my-nav-checkbox > label to

    .ui-jqgrid .ui-pg-table .my-nav-checkbox > label {
        margin: 0px;
        border-width: 0px;
    }
    .ui-jqgrid .ui-pg-table .my-nav-checkbox:hover > label {
        margin: 0px;
        border-width: 1px;
    }
    

    As the result you will have (see the following demo):

    • standard state button enter image description here
    • hover state of the button enter image description here
    • standard state “checked” button enter image description here
    • hover state of the “checked” button enter image description here
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the code below (from a console app I've cobbled together), I add seven
I am creating a random ID using the below code: from random import *
I have the code below: string SQL = select * from + TableName; using
My original question I've managed to answer by cobbling other answers together from this
While testing the below SQL code for another stackoverflow answer , I got the
THe code below I copied from MSDN with a bit of modification: [DllImport(user32.dll, CharSet
I got below code from http://msdn.microsoft.com/en-us/library/dd584174(office.11).aspx for adding custom property in webpart tool pane.
Please have a look at the code below: import string from collections import defaultdict
The code below correctly returns the XML from the soap sever that I'm accessing.
From the code below I am getting a cell value from the selected row

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.