views:

827

answers:

2

I just took a look at jqgrid. Has anyone tried implementing this plugin, or used jQuery, to achieve server side pagination?

I am using struts2 and populating a html table with list returned from DB. This list is returned from an Oracle SP. The SP, along with some other parameters, is taking in 'start' and 'begin'. So I can pass numbers to these parameters to get specific row counts.

How would you achieve this? I would prefer some 'ajaxy' solution where the whole page does not refresh but just the table section refreshes. I see this is done on SO as well, but I think in this case they are bringing back all the data at once.

A: 

Most of the javascript grids assume you will have all of the data ready for display to start with -- mostly because they do client side sorting.

Since you want to do paging on the server side, that isn't going to work.

My suggestion, define a good web service and do it yourself. You could use JTemplate to help build the table after each web service request. If you want to keep it simple, don't do sorting.

Chris Brandsma
+1  A: 

I've successfully used http://www.datatables.net/ - a jQuery plugin that does server-side data and pagination.

Here's a basic implementation of datatables (version 1.5 beta 3) that uses server-side paging: http://artlung.com/temp/comics/.

artlung
I dont see any support for server-side pagination. any hints you have?
Omnipresent
The current release is 1.4.3. The server side-support is in 1.5 beta 3 alone. http://datatables.net/forums/comments.php?DiscussionID=53 - I'm sorry for the lack of clarity.
artlung
I've added a link to a basic implementation of datatables in my answer: http://artlung.com/temp/comics/
artlung
thank you. this will require me to send data in json format right? is that the only data format it will accept to accomplish this?
Omnipresent
it would help if you could post the data.php code somewhere as well
Omnipresent
@Omnipresent yes, the data is in a predefined JSON format. Here's how I do it, though probably there would be other ways to go about it: http://artlung.com/temp/comics/source-to-data.php If you have any questions feel free to ask!
artlung