PDA

View Full Version : Java + JsonData + grid + paging + data loading



diuxa
14 Feb 2008, 5:45 AM
Hi!

I using Ехт js in the Tapestry project. I'm using grid with paging.
In grid data is stored with JsonData, Which is formed that way:
1. From database I load completely weight the list.
2. In page class MyPage.java with method getJsonData() forming such string.
method getJsonData()


public String getJsonData() {
String results = new String();

results += "{\"totalCount\":\""+getSearchResults().size()+"\",";
results += "\"rows\":[";
int id = 1;
for(Long element : getSearchResults()) {
String item = new String("");
item += "{";
item += "\"id\":\""+(id++)+"\",";
item += "\"element\":\""+element+"\"";
item += "}";
if(id > 2)
results += ",";
results += item;
}
results += "]}";
return results;
}

This string after looks that:


{"totalCount":"3","rows":[{"id":"1","element":"444907"},{"id":"2","element":"444908"},{"id":"3","element":"444909"}]};

3. This string I transfer to my script file.

I'm using Ext.data.MemoryProxy, Ext.data.Store, Ext.data.JsonReader. And don't using php.

Wished to ask, as it is possible to make that every klick to a new page inner the paging grid (on the bbar) causes the method getJsonData() (in MyPage.java file) and forming a next data portion for this page in grid.

cheek
14 Feb 2008, 8:36 AM
Hi,
I'm not very sure what you want to do (red your last sentence minimum 10 times =; )

What kind of data store do you use? What kind of data reader?

I'm using Ext.data.Store with Ext.data.HttpProxy and Ext.data.Json Reader

Serverside I'm using php and on the base of the store.load() properties, I'm forming my database query

every klick to a new page inner the paging grid (on the bbar) causes a new db query(including sending a new json string from server to client)


could you restate your question? :D