views:

304

answers:

3

I can see from the jqGrid JSON data being posted to the browser that the row ID (denoted by "i" in the JSON row data) is coming through correctly, but when I make a selection and check the $('#list').getGridParam('selarrrow') it is showing the selected row numbers as opposed to their IDs.

Does anyone have experience with this? Thanks

UPDATE

Below is a picture of the JSON result (copy and paste not really an option)

(bigger version of the image here)

JSON Result

And the javascript code to check the selection:

<script type="text/javascript">
    function checkSelection(){
        alert($('#list').getGridParam('selarrrow').join());
    }
</script>
A: 

Are you sure? According to the jqGrid documentation for selarrrow:

This options is read only. Determines the currently selected rows when multiselect is set to true. This is one dimensional array and the values in the array correspond to the selected id's in the grid.

So if it is returning row numbers there is a bug in the jqGrid API. Would it be possible for you to post more information, such as the result of your call to selarrrow as well as a full listing of the ID's in the grid?

Justin Ethier
A: 

I suppose that IDs which be send from the server are ignored and so row numbers will be the real row ids. You can verify this with getDataIDs method inside of loadComplete event. Why the IDs will be ignored I could say only if your post more information.

Oleg
A: 

Justin and Oleg - Im certain that you were put on this planet to solve the world's jQueries :) Thanks again for your assistance with this problem.

SOLUTION
In my code, the grid's column definitions didnt specify a key column from which to draw each row's ID from - how it was getting the i = <id> in the screenshot above, I have no idea, but it definitely wasn't using that ID for each row. I changed the grid definition to the following:

...,
colNames: ['ID', 'Family', 'Variety', 'Type', 'EDI #', 'Colour', 'Swatch'],
colModel: [{ name: 'id', index: 'id', key: true, hidden: true },
...

(notice the key: true in the colModel for the ID column)

Jimbo