PDA

View Full Version : Infinite grid end?



gtsafas
2 Jul 2012, 9:19 AM
Hi, I am using a buffered grid. The issue I am having is when I scroll to the last record in my dataset it triggers another reload. I am setting pageSize to 200 and the row count is the total count of my dataset. Any idea what I may be doing wrong?

martinrame
2 Jul 2012, 11:34 AM
Could you paste your store definition?, the problem could be the store is not receiving the total number of elements in your dataset, if you are using an "ajax" proxy in your store, you must include a Reader with the property "totalProperty" pointing to the total property of your json.

Please, paste your store definition, and part of your JSON dataset (if you are using json).

gtsafas
2 Jul 2012, 11:41 AM
Thanks for replying, see below



{"nrows": 1400,"rows": [{"12/7/2012__Price": 2145,"12/8/2012__Ask": 2618,"12/7/2012__Bid": 2144,
"12/8/2012__Bid": 2620,"12/7/2012__Ask": 2147,
"CellTipText": "Symbol=ZVZZT","12/8/2012__Price": 2617,"id": "0"},{"12/7/2012__Price": 2145,"12/8/2012__Ask": null,"12/8/2012__Bid": null,"12/7/2012__Bid": 2144,"CellTipText": "Symbol=ZVZZT, Date=12/7/2012","12/7/2012__Ask": 2147,
"12/8/2012__Price": null,"id": "0.0"},{.......


store


Ext.create("Ext.data.Store",{'autoLoad': True,
'buffered': True,
'fields': [{'name': 'Symbol', 'type': 'string'},
{'dateFormat': 'Y-m-d', 'name': 'Date', 'type': 'date'},
{'name': 'Currency', 'type': 'string'},
{'name': '12/7/2012__Ask', 'type': 'float'},
{'name': '12/7/2012__Price', 'type': 'float'},
{'name': '12/7/2012__Bid', 'type': 'float'},
{'name': '12/8/2012__Ask', 'type': 'float'},
{'name': '12/8/2012__Price', 'type': 'float'},
{'name': '12/8/2012__Bid', 'type': 'float'}],
'pageSize': 300,
'proxy': {'reader': {'root': 'rows',
'totalProperty': 'nrows',
'type': 'json',
'useSimpleAccessors': True},
'type': 'ajax',
'url': '/data'},
'remoteSort': True})

martinrame
2 Jul 2012, 11:49 AM
How much records are your returning on each call to store.load() ?.

Each time the store tries to load data, it sends the params "start" and "limit" to your server, i.e,:

http://localhost/data?start=0&limit=300

So, on server side, you must handle that limit, and return only 300 rows, BUT in your "nrows" field, return the total count (1400) as you did.

gtsafas
2 Jul 2012, 11:52 AM
yeah, but the last set may not be guaranteed to be 300.

martinrame
2 Jul 2012, 12:29 PM
It doesn't matter, the store knows how to handle this.

In your example, you've set pageSize to 300, so, each page is handled this way:

Page 1: from 1 to 300
Page 2: from 301 to 600
Page 3: from 601 to 900
Page 4: from 901 to 1200
Page 5: from 1201 to 1400

You just need to handle the values requested by the store, start and limit, and return total rows (nrows) every time a request is made.

gtsafas
3 Jul 2012, 5:15 AM
Would it be impacted because I call store load again? the nrows number updates accordingly to accomidate the new dataset