Paged Grid Using a directjngine Back-end

Paged Grid Using a directjngine Back-end

I am trying to implement a paged grid panel using a directjngine back-end. In the long term, what I'd like to do is create a buffered (infinite) grid, where paging is handled when you scroll through the grid, but getting it working with paging is the first step.

Currently I'm able to display a grid panel with a paging toolbar and load the first page by subsetting the data to be returned. Unfortunately, I'm not sure how to pass back the total number of records (so the paging toolbar will show "Displaying 1 - X of Y" [where Y > X] and enable the next button). Directjngine allows you to use annotations to indicate which Java methods are callable from ExtDirect, like so:

Where the "total": "565" line between the end of the result array and the "type": "rpc" field is new. But how can I configure (or extend) directjngine to pass back the total number of records in the data-set as a new JSON property outside of the result property?

Last edited by adavis2; 25 Oct 2012 at 6:52 AM.
Reason: Showed the desired output and rephrased the final question.

But how can I configure (or extend) directjngine to pass back the total number of records in the data-set?

The best way to pass complex info back and forth is to define and then receive/return classes that hold the required data: if you want a 'total' value back, add to the class holding the data you return a 'total' field.

This does not display as desired in my gridPanel (it shows as one empty row). So I guess my revised question is how can I configure (or extend) directjngine to pass back the total number of records in the data-set as a new JSON property outside of the result property?

Hmm, at a glance, your class structure looks ok...have you set your store.proxy.reader.root config value to 'result' before store creation?

DJN has always allowed me to implement all I needed, even much more complex dynamic structures. The problem tends to be in defining classes the way ExtJs wants them, and configuring ExtJs object the way it wants.

In many cases DJN is pointed as the one with "the issue", when the real "issue" lies in the ExtJs side... kind of discouraging for me, as the author of DJN

I do appreciate your help. In general DirectJngine is working great for me. I just can't get it to work with a paged (or infinite) grid. Or maybe I can't get (ExtJS) paged grids to work with DirectJngine. Anyway, I'm trying to come up with a smaller example that shows the problem -- something I can post here. But that will have to wait for Monday.

Smaller example

Smaller example

Here is a smaller example that shows the problem I am having: extDjnSample-src-main.zip. I have a simple grid which can contain a large number of rows. I can get it to load all of the data, but I would like to load the data 20 rows at a time. I can get it to load the first page, but it doesn't show the correct total page or record counts (or allow me to change pages):

Working Example

Working Example

I have resolved the problem I was having. Here is a working example that shows the same data loaded 4 different ways. The application has 4 tabs, each tab containing a simple grid which can contain a large number of rows. The first 2 tabs show tables with all of the 241 rows loaded at once. The 3rd tab shows the data broken into pages of 20 rows each. The 4th tab shows the same data loaded into an "infinite" (buffered) grid.

The 'paged' tab of this example is almost the same as my previous simple example. The 3 differences between them are:

Data is now returned in a PartialResult object, which adds the "total" property to the JSON result.

I upgraded ExtJS from 4.1.0 to 4.1.1.

I upgraded DirectJngine from 2.1 to 2.2.

Since I had tried the PartialResult technique before, I believe the ExtJS upgrade made the difference. Anyway, I'm uploading this new example in case it's helpful to others.extDjnSample-src-main.zip