How to get a page number by row id in jqGrid

After loading a JSON (using loadonce: true) I get a paged grid.

Now, on gridComplete callback I'd like to jump to page that contains a row (specified by ID).

I'm frustrated that there is no solution as far. I've triead a setSelection method, but it selects the row only if it's on current page.

Answers


Well, you only have one page of data returned to the grid at a time. Part of that JSON packet should be the total number of pages that exist in the record set given your "per page" setting.

I'd suspect you'd have to craft a stored procedure that generates your record set, determines the pages of data, then filters down to the page that contains the requested record ID and return that page, rather than the first page in the set. This seems to be more trouble (and more overhead) than if you just return a single record based on your record ID.


I believe, if you are doing a loadonce:true, then you are returning all the data from the server, You could iterate through all the records on the client side once the data is loaded to find the correct rowID, and calculate which page its on, then set that row and/or page once found.

Check out this post,

JQGrid Programatically Select Grid Row

it has examples and code.


Need Your Help

Non-cycle path to all nodes

algorithm graph graph-theory shortest-path traveling-salesman

Is there an algorithm or set of algorithms that would let you find the shortest walking distance from an arbitrary start node so that every node gets visited in a weight, undirected graph? It's not...

jquery .post not triggering

jquery ajax post .post

I can't seem to get jquery .post to actually trigger. Where is the glaring hole? The alert functions on click, but not the post. Doesn't show up in firebug console either...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.