PDA

View Full Version : store's bug



ueohir
28 Mar 2010, 2:15 AM
store using xmlReader,totalCount is error.
3.1 and 3.2beta
sorry,my English is poor.

fay
28 Mar 2010, 5:14 AM
Can you post a proper (http://www.extjs.com/learn/Ext_Forum_Help#Proper_Posting) description of the problem?

Do you mean that calling the store's getTotalCount() (http://www.extjs.com/deploy/dev/docs/?class=Ext.data.Store&member=getTotalCount) method returns 0? Are you sure that you are checking it after the store has been loaded, and not after you call load() but in the 'load' event handler?

The docs for getTotalCount() says:


Gets the total number of records in the dataset as returned by the server.
If using paging, for this to be accurate, the data object used by the Reader must contain the dataset size. For remote data sources, the value for this property (totalProperty for JsonReader, totalRecords for XmlReader) shall be returned by a query on the server. Note: see the Important note in load.

I'm not certain, but I think there might be a mistake in that it should read totalProperty (http://www.extjs.com/deploy/dev/docs/?class=Ext.data.XmlReader&member=totalProperty) and not totalRecords for XmlReader.

ueohir
28 Mar 2010, 5:46 PM
This is ExtJs3-API doc:

The xml is:
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
<results>20</results>
<row>
<id>1</id>
<name>Bill</name>
<occupation>Gardener</occupation>
</row>
<row>
<id>2</id>
<name>Ben</name>
<occupation>Horticulturalist</occupation>
</row>
</dataset>

js code:

var Employee = Ext.data.Record.create([
{name: 'name', mapping: 'name'}, // ??????????"mapping"????"mapping" property not needed if it's the same as "name"
{name: 'occupation'} // This field will use "occupation" as the mapping.
]);
var myReader = new Ext.data.XmlReader({
totalRecords: "results", // ??????????????????
record: "row", // ?????????????????
id: "id" // ??????????????????????ID????????
}, Employee);
var ds = Ext.data.Store({
reader:myReader,
proxy:new proxy()
});


ds.getTotalCount() is 2, not 20. but in version 2.0.2 and 3.0 , ds.getTotalCount() is 20.