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.
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.