JQgrid - Get Row Number instead of ID

Posted by mariojjsimoes on Stack Overflow See other posts from Stack Overflow or by mariojjsimoes
Published on 2010-05-10T01:11:08Z Indexed on 2010/05/10 1:18 UTC
Read the original article Hit count: 1183

Filed under:
|
|
|

Hello, all,

I am creating a JQGrid from a database table that does not contain a single field primary key. Therefore, the field i am supplying as id is not unique and the same one exists in several rows.

Because of this, when passing a reference to the data with ondblClickRow to a function external to the grid i need to use the rownumber and not the id.

To test, I'm using ondblClickRow: function(id){alert($("#grid1").getInd('rowid'));}, , and i should be getting and alert with the row number, except that it isn't working.

I've been over the documentation and can't understand what i am doing wrong...

Any help would be greatly appreciated!

Thanks in advance, Mario.

Bellow is my full grid:

jQuery(document).ready(function(){
var mygrid = jQuery("#grid1").jqGrid({
    datatype: 'xmlstring',
    datastr : grid1RsXML,
    width: 1024,
    height: 500,
    colNames:['DEVICE_ID','JOB_SIZE_IN_BYTES', 'USER_NAME','HOST_NAME','DAY_OF_WEEK','JOB_ID'],
    colModel:[ 
                {name:'DEVICE_ID',index:'DEVICE_ID', width:55, sortable:true},
                {name:'JOB_SIZE_IN_BYTES',index:'JOB_SIZE_IN_BYTES', width:40, sortable:true},
                {name:'USER_NAME',index:'USER_NAME', width:60, sortable:true},
                {name:'HOST_NAME',index:'HOST_NAME', width:50,align:"right", sortable:true},
                {name:'DAY_OF_WEEK',index:'DAY_OF_WEEK', width:10, sortable:true},
                {name:'JOB_ID',index:'JOB_ID', width:30, sortable:true}

             ],
    rowNum:1000,
    autowidth: true, 
    //rowList:[10,20,30],
    rowList:[1],
    pager: '#grid1Pager',
    sortname: 'DEVICE_ID',
    viewrecords: true,
    rownumbers: true,
    sortorder: "desc",
    sortable: true,
    gridview : true,
    xmlReader: { root : "recordset", row: "record", repeatitems: false, id: "DEVICE_ID" },
    caption:"All Jobs - Double Click for detailed history",
    ondblClickRow: function(id){alert($("#grid1").getInd('rowid'));}, 
    toolbar: [true,"top"],
    url: grid1RsXML
});

© Stack Overflow or respective owner

Related posts about jqgrid

Related posts about method