PDA

View Full Version : Grouping Grid Performance Issue



vbjain
8 Jul 2010, 5:44 AM
Hello All,

I am using grouping grid provided in GXT Showcase (http://www.sencha.com/examples/#grouping). Grid is running fine until it have thousand of records. But when i insert record upto 80,000 - 1 Lakh then grid is getting crashed.

Do anyone have any idea about this? If pagination is solution then can you give any example of Pagination on Grouping Grid?

Waiting to hear some words from you.

I am using: GXT 2.0.1

Below is my code:
GroupingGridExample.java

public class GroupingGridExample extends LayoutContainer {

@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);

setLayout(new FlowLayout(10));

GroupingStore<Stock> store = new GroupingStore<Stock>();
store.add(TestData.getCompanies());
store.groupBy("industry");

ColumnConfig company = new ColumnConfig("name", "Company", 60);
ColumnConfig price = new ColumnConfig("open", "Price", 20);
ColumnConfig change = new ColumnConfig("change", "Change", 20);
ColumnConfig industry = new ColumnConfig("industry", "Industry", 20);
ColumnConfig last = new ColumnConfig("date", "Last Updated", 20);
last.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/y"));

List<ColumnConfig> config = new ArrayList<ColumnConfig>();
config.add(company);
config.add(price);
config.add(change);
config.add(industry);
config.add(last);

final ColumnModel cm = new ColumnModel(config);

GroupingView view = new GroupingView();
view.setShowGroupedColumn(false);
view.setForceFit(false);
view.setGroupRenderer(new GridGroupRenderer() {
public String render(GroupColumnData data) {
String f = cm.getColumnById(data.field).getHeader();
String l = data.models.size() == 1 ? "Item" : "Items";
return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
}
});

Grid<Stock> grid = new Grid<Stock>(store, cm);
grid.setView(view);
grid.setBorders(true);

ContentPanel panel = new ContentPanel();
panel.setHeading("Grouping Example");
panel.setCollapsible(true);
panel.setFrame(true);
panel.setSize(700, 450);
panel.setLayout(new FitLayout());
panel.add(grid);

add(panel);
}

}

TestData.java

public static List<Stock> getCompanies() {
DateTimeFormat f = DateTimeFormat.getFormat("M/d h:mma");
List<Stock> stocks = new ArrayList<Stock>();
for (int i = 0; i < 1000; i++) {
stocks.add(new Stock("3m Co" + i, 71.72, 0.02, 0.03, f.parse("4/2 12:00am"),
"Manufacturing" + i));
}
return stocks;
}

Stock.java

public class Stock extends BaseModel {

public Stock() {
}

public Stock(String name, String symbol, double open, double last) {
set("name", name);
set("symbol", symbol);
set("open", open);
set("last", last);
set("date", new Date());
set("change", last - open);
}

public Stock(String name, double open, double change, double pctChange, Date date, String industry) {
set("name", name);
set("open", open);
set("change", change);
set("percentChange", pctChange);
set("date", date);
set("industry", industry);
}

public String getIndustry() {
return get("industry");
}

public void setIndustry(String industry) {
set("industry", industry);
}

public Date getLastTrans() {
return (Date) get("date");
}

public String getName() {
return (String) get("name");
}

public String getSymbol() {
return (String) get("symbol");
}

public double getOpen() {
Double open = (Double) get("open");
return open.doubleValue();
}

public double getLast() {
Double open = (Double) get("last");
return open.doubleValue();
}

public double getChange() {
return getLast() - getOpen();
}

public double getPercentChange() {
return getChange() / getOpen();
}

public String toString() {
return getName();
}

}

Thanks,
Vipul

sven
8 Jul 2010, 6:03 AM
80000 rows are not even going to work on a normal grid. This is jsut far to much. You should really rething your design. Which human person can see80000 rows?

vbjain
8 Jul 2010, 6:14 AM
Thanks for reply.

I had some weird requirement of it.

Anyway if not this much row then 40 Columns and 6000 - 10,000 Rows can be possible. Still grid is getting crashed.

Please suggest if you have any solution for it. That is really required.

Thanks for having look.

sven
8 Jul 2010, 6:18 AM
I dont have any solution for this i can give out. We are looking into changing the grid dom layout to improve the speed. However 80000 rows will never going to work in old browsers.