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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:53:31+00:00 2026-05-24T13:53:31+00:00

I’ve implemented a jqgrid with inline edit: var lastSel; jQuery(document).ready(function () { jQuery(#list).jqGrid({ url:

  • 0

I’ve implemented a jqgrid with inline edit:

var lastSel;

    jQuery(document).ready(function () {

        jQuery("#list").jqGrid({
            url: '/Home/DynamicGridData/',
            datatype: 'json',
            mtype: 'POST',
            colNames: ['Actions', 'Id', 'note', 'tax'],
            colModel: [
            {name:'act',index:'act',width:55,align:'center',sortable:false,formatter:'actions',
                     formatoptions:{
                         keys: true, // we want use [Enter] key to save the row and [Esc] to cancel editing.
                         onEdit:function(rowid) {
                             alert("in onEdit: rowid="+rowid+"\nWe don't need return anything");
                         },

                         },},
              { name: 'Id', index: 'Id', width: 55,align:'center', editable: false },
              { name: 'note', index: 'note', width: 40,align:'center', editable: true },
              { name: 'tax', index: 'tax', width: 40,align:'center', editable: true}],
            pager: jQuery('#pager'),
            rowNum: 10,
            rowList: [5, 10, 20, 50],
            sortname: 'Id',
            sortorder: "desc",
            viewrecords: true,
            imgpath: '',
            caption: 'My first grid',
            editurl: '/Home/Save/'
        });
        jQuery("#list").navGrid('#pager', { edit: false, search: false, add: false });
    }); 

The problem is that it’s not working as expected. The problem is that when the grid loads the Id data is loaded into the Actions column, the note data is added into the Id column and the tax data is added into the note column. The tax column is empty. I think this is because when the data is loaded there is nothing currently in the Actions column?

Anyway when the actions icon buttons load they load in the Actions column which is correct but over top of the Id data which is in the wrong column.

I’ve compared this with other working examples but so far have not found the problem.

EDIT:

Have just found this problem occurs with the json data but not local data.

So if you feed it Json data like:

public JsonResult DynamicGridData2(string sidx, string sord, int page, int rows)
        {
            int totalPages = 1; // we'll implement later
            int pageSize = rows;
            int totalRecords = 3; // implement later

            var jsonData = new {
                total = totalPages,
                page = page,
                records = totalRecords,
                rows = new[]{
                    new {id = 1, cell = new[] {"1", "Note1", "Tax1"}},
                    new {id = 2, cell = new[] {"2", "Note2", "Tax2"}},
                    new {id = 3, cell = new[] {"3", "Note3", "Tax3"}}
                }
            };
            return Json(jsonData);
        }

The error happens. However if you give it local data like:

data: mydata,
datatype: 'local',

var mydata = [
                    {id:"1", note:"Note1", tax:"Tax1"},
                    {id:"2", note:"Note2", tax:"Tax2"},
                    {id:"3", note:"Note3", tax:"Tax3"}
                ]

It’s fine.

  • 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-24T13:53:32+00:00Added an answer on May 24, 2026 at 1:53 pm

    I can suggest you two solution of the problem. The first one is very easy. You should include “” as the first column in the cell array:

    public JsonResult DynamicGridData2(string sidx, string sord, int page, int rows)
    {
        // ...
        var jsonData = new {
            // ...
            rows = new[]{
                new {id = 1, cell = new[] {"", "1", "Note1", "Tax1"}},
                new {id = 2, cell = new[] {"", "2", "Note2", "Tax2"}},
                new {id = 3, cell = new[] {"", "3", "Note3", "Tax3"}}
            }
        };
        return Json(jsonData);
    }
    

    In the case the code will produce the following JSON data

    {
        "total": "1",
        "page": "1",
        "records": "3",
        "rows": [
            { "id": "1", "cell": ["", "1", "Note1", "Tax1"] },
            { "id": "2", "cell": ["", "2", "Note2", "Tax2"] },
            { "id": "3", "cell": ["", "3", "Note3", "Tax3"] }
        ]
    }
    

    and the data will be correctly displayed: see the first demo here.

    The other way which I can suggest is to use the same server code as before, but to define on the client side how the data will be read:

    colModel: [
        {name: 'act', index: 'act', width: 55, sortable: false, formatter: 'actions',
            formatoptions: {
                 // we want use [Enter] key to save the row and [Esc] to cancel editing.
                 keys: true,
                 onEdit:function(rowid) {
                     alert("in onEdit: rowid="+rowid+"\nWe don't need return anything");
                 }
            },
            jsonmap: function (obj) { return ''; }},
        { name: 'Id', index: 'Id', width: 55,
            jsonmap: function (obj) { return obj.cell[0]; } },
        { name: 'note', index: 'note', width: 40, editable: true,
            jsonmap: function (obj) { return obj.cell[1]; } },
        { name: 'tax', index: 'tax', width: 40, editable: true,
            jsonmap: function (obj) { return obj.cell[2]; } } ],
    jsonReader: { repeatitems: false },
    cmTemplate: { align: 'center' }
    

    See the next demo here.

    In the example I defined first of all the jsonReader: { repeatitems: false } parameter which allows us to use not only arrays with one-to-one order like the column order in the colModel. Now we can use jsonmap which defines to read the column contain from the row object like

     { "id": "1", "cell": ["1", "Note1", "Tax1"] }
    

    for example. The id property (not ‘Id’) will be read in the standard way by jqGrid. To read any other cell contain from the row of JSON data the jsonmap function will be called. We return just the correct string from the cell array.

    It is relatively clear to understand that you can simplify and reduce the size of the JSON data if you replace the row which represent the data to

    ["1", "Note1", "Tax1"]
    

    In the case you should just add key: true property for the 'Id' column and change the jsonmap functions. For example for the 'tax' column it should be jsonmap: function (obj) { return obj[2]; } }.

    At the end I would recommend you to take a look in the UPDATED part of the answer where you can download VS2008 or VS2010 demo project. It seems to me the demos could be helpful for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.