Reputation: 561
I'm using Jqgrid to display a table, and I have a auto increment primary key as the tables primary key.The data is grouped by an orderDate but I don't know how to access values of the same orderDate through Jqgrid.
I use this to find the selected row
var rowKey = grid.getGridParam("selrow");
and it returns a value, and if the data was neat I would just add 1 to get the correct index for the data I want, but the values are often far off from each other.
I can group the data together in the table through modifying the SQL but the table still seems to retain orderDate as the index.
Is there an easy way I can just select the next row of the grid? Or at least find its index?
Thanks.
Upvotes: 3
Views: 8348
Reputation: 11
Maybe you could consider using CellSelect(gets rowId) and BeforeEditCell(iRow and iCol) in my case i increment the value by 1 or decrease and use it to browse the grid with arrow keys. IRow and ICol is the your row and col index
but that would mean that you wouldn't use Forms to edit(i guess), rather like exel cell by cell editing
Then on edit you can do rowEdited[e.AllKeys[0]] = e.AllKeys[0]; to assign values and store ids in session then saveToDb on Server Button "Complete_Click"
or maybe pass like 'clientArray' saing SAVENOW! (still experimenting with that) to saveToDb on inline save button click. Just an idea:)
Upvotes: 0
Reputation: 16955
You can use the "getInd" method to find the index of the row you're working with, like so:
var idx = grid.getInd(rowKey);
You can also get the array of ID values from your grid like so (ordered as they are in your grid display):
var dataIDs = grid.getDataIDs();
Together, you can get the id for the next row in your grid:
var nextID = (dataIDs.length < idx+1) ? dataIDs[idx+1] : dataIDs[0];
(Here I assume that if you hit the end of your list, you want to wrap around to the beginning - you get the idea)
Upvotes: 3