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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:45:32+00:00 2026-06-04T23:45:32+00:00

I have used jqgrid for a while. I am getting an error when I

  • 0

I have used jqgrid for a while. I am getting an error when I select a row:

> Uncaught TypeError: Cannot call method 'indexOf' of undefined
> jquery.jqGrid.src.js:2465 $.jgrid.extend.setSelection
> jquery.jqGrid.src.js:2465 jQuery.extend.each jquery-1.7.1.js:658
> jQuery.fn.jQuery.each jquery-1.7.1.js:271 $.jgrid.extend.setSelection
> jquery.jqGrid.src.js:2460 $.fn.jqGrid jquery.jqGrid.src.js:587
> $.fn.jqGrid.each.$.before.click.bind.ts.p.datatype
> jquery.jqGrid.src.js:2235 jQuery.event.dispatch jquery-1.7.1.js:3256
> jQuery.event.add.elemData.handle.eventHandle

my grid definition is here:

var sql4 = 'select id_num, est_number, customer, product, rev, w, l, fw, fl, expr1009, status, comments from schema.table where customer = "' + customer + '" and est_number = "' + est_num + '"';
$("#the_table").jqGrid({
    url:'thescript.php?sql=' + sql4,
    height: 300,
    shrinkToFit: true,
    width: 650,
    datatype: 'xml',
    mtype: 'POST',
    colNames:["ID","Estimate","Customer","Product","Rev","W","L","FW","FL","Expr1009","Status","Comments"],
    colModel:[
        {name:"id_num",index:"id_num",width:"10"},
        {name:"est_number",index:"est_number",width:"10"},
        {name:"customer",index:"customer",width:"10"},
        {name:"product",index:"product",width:"10"},
        {name:"rev",index:"rev",width:"10"},
        {name:"w",index:"w",width:"10"},
        {name:"l",index:"l",width:"10"},
        {name:"fw",index:"fw",width:"10"},
        {name:"fl",index:"fl",width:"10"},
        {name:"expr1009",index:"expr1009",width:"10"},
        {name:"status",index:"status",width:"10"},
        {name:"comments",index:"comments",width:"10"}
    ],
    rowNum:10000,
    sortname: 'id_num',
    sortorder: 'asc',
    viewrecords: true,
    gridview: true,
    caption: '',
    ondblClickRow: function(id){
        //do some stuff here
    }
})
.jqGrid('filterToolbar')
.trigger('reloadGrid');

}

I cannot figure out what the problem is, as it seems the grid works fine otherwise.

I have noticed that in the following jqgrid function, the id = 1 for ever row (this info is contained in the variable pt.

setSelection : function(selection,onsr) {
    return this.each(function(){
        var $t = this, stat,pt, ner, ia, tpsr;
        if(selection === undefined) { return; }
        onsr = onsr === false ? false : true;
        pt=$t.rows.namedItem(selection+"");

The next line is where the error occurs. The variable pt has 4 nodes that all have id: 1.

if(!pt || pt.className.indexOf( 'ui-state-disabled' ) > -1 ) { return; }

** Amswer **

I added the key:true option the the id_num field in the ColModel. Each row of the grid had the SAME ID, so it was causing a problem. I think is error happens most often when you do not have unique IDs. in your grid.

  • 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-04T23:45:34+00:00Added an answer on June 4, 2026 at 11:45 pm

    I think that you should use encodeURIComponent in any way:

    url: 'thescript.php?sql=' + encodeURIComponent(sql4)
    

    instead of

    url: 'thescript.php?sql=' + sql4
    

    Probably you should send sql parameter not as the part of URL, but inside of POST data. In the case you should use

    url: 'thescript.php',
    postData: {
        sql: function () {
            return 'select id_num, est_number, customer, product, rev, w, l, fw, fl,' +
                ' expr1009, status, comments from schema.table where customer = "' +
                customer + '" and est_number = "' + est_num + '"';
        }
    }
    

    UPDATED: The error will be in the lines of code of setSelection. So pt.className is undefined. It’s very strange, but you can validate that you have no id duplication in the grid.

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

Sidebar

Related Questions

I have a custom method for getting a string which is used with jqGrid
I have used full text search mysql. My code is select * from uh_property
I have used BaseAdapter for grid view, in getView method of BaseAdapter I am
I have used jqGrid Treeview Adjacency model to display the hierarchy. Treeview works perfectly
In the past when I've used jqgrid all i have done is had a
I have made one JQgrid which calls Ajax for getting data on loading the
I have a button used to delete a row when checked that calls the
Hi I have a grid which used to display call details. It is displaying
I have used IPC in Win32 code a while ago - critical sections, events,
I am using jQuery 1.4 and jqGrid 3.8 beta, Here I have used jqgrid

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.