Search code examples
jqueryjqgridmulti-select

jqGrid 'selarrrow' returning row numbers instead of row IDs


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>

Solution

  • 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)