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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:27:24+00:00 2026-06-01T05:27:24+00:00

My goal is to inline edit cells in a data grid using JQuery and

  • 0

My goal is to inline edit cells in a data grid using JQuery and JqGrid. I got the grid to populate based on an ajax request and json reponse. Unfortunately I can’t get the cells to become editable when clicking on rows.

I tried both Chrome and Safari and did two days of research and still no luck. The links I used below didn’t help:

http://trirand.com/blog/jqgrid/jqgrid.html

http://www.trirand.net/demoaspnetmvc.aspx

Following the tutorials I added an onRowSelect event that would call editRow and set the value to true. However it never works and I can’t figure out why.

Any help would be greatly appreciated.

Code:

<html>
<head>
    <title>Test</title>

    <link rel="stylesheet" type="text/css" href="ui.jqgrid.css"/>
    <link rel="stylesheet" type="text/css" href="jquery-ui-1.8.2.custom.css"/>

    <style type="text/css">
    html, body {
        margin: 0;
        padding: 0;
        font-size: 75%;
    }
    </style>


    <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    <script src="i18n/grid.locale-en.js" type="text/javascript"></script>
    <script src="jquery.jqGrid.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function() {

            jQuery("#list").jqGrid({
                        url:'http://localhost:8080/jblog/messages',
                        datatype:'json',
                        jsonReader: {
                            root: 'rows',
                            repeatitems: false,
                            page:  'currentPage',
                            total: 'totalRecords'
                        },
                        mtype:'GET',
                        colNames:['Message ID', 'Message Content'],
                        colModel:[
                            {name:'messageId', index:'messageId'},
                            {name:'content', index:'content', width:'400'}
                        ],
                        viewrecords:true,
                        caption:'My first grid',
                        rowNum:30,
                        rowList:[10,20,30],
                        pager: '#pager',
                        sortname: 'messageId',
                        onSelectRow: function(id){
                            console.log('onSelectRow');
                            editRow(id);
                            },
                        editurl:'http://localhost:8080/jblog/messages'
                    });
        });
    </script>

</head>
<body>
<table id="list">
    <tr>
        <td/>
    </tr>
</table>
<div id="pager"></div>
<script type="text/javascript">
           var lastSelection;

           function editRow(id) {
               console.log("editRow");
               if (id && id !== lastSelection) {
                   console.log("setRowToEdit");
                   var grid = $("#list");
                   grid.restoreRow(lastSelection);
                   console.log("id " + id);
                   grid.editRow(id, true);
                   lastSelection = id;
               }
           }
</script>
</body>
</html>
  • 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-01T05:27:26+00:00Added an answer on June 1, 2026 at 5:27 am

    The main error in your code is:

    • you have to include editable: true property in the columns which you need to edit.

    Additionally you should do following changes in the code:

    • you should include <!DOCTYPE html ...> line before <html> which declare the dialect of HTML/XHTML which you use. If you use HTML5 dialect the line will be just <!DOCTYPE html>. In you case it seems can be the line <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> which corresponds XHTML 1.0 Strict. See the documentation for more details.
    • I recommend you reduce the number of global variables. The variable lastSelection and the function editRow should be just in outer scope of onSelectRow. So you can move there inside of $(document).ready(function() {/*here!!!*/}); block. I would recommend you better to use anonymous functions and place the code of editRow directly in the code of onSelectRow. By the way you can use $(this) instead of $("#list") inside of onSelectRow. It makes the code a little bit quickly and improves the maintenance of the code because you can easier cut & paste the code fragments.
    • you should never use prefixes like http://localhost:8080/ in the Ajax requests (see url and editurl options). Instead of that you should use url:'/jblog/messages' or url:'jblog/messages' URLs. Access to another server as the current server from which the current page are loaded or access of another port is prohibited because of same origin policy of Ajax.
    • I recommend you always use gridview: true jqGrid options which can improve performance of the grid.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a jQuery and the tablesorter plugin in my web page. My goal
Goal: Create Photomosaics programmatically using .NET and C#. Main reason I'd like to do
Goal : Our application is built using multiple types (e.g. Person, PersonSite(ICollection), Site -
goal : I want to place a text after the submit button using hook_form_alter.
Goal: To render a google map using geolocation. I am trying to implement the
My goal is to submit a form in a Colorbox modal via ajax (that
I am using MPMoviePlayerController in my UIView and the goal is to put it
I wrote some jQuery code in an external file, with the goal to match
Goal: Display textbox and submit button on the same line in Jquery Mobile. Problem:
Goal Java client for Yahoo's HotJobs Resumé Search REST API . Background I'm used

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.