PDA

View Full Version : XMLStore retrieve totalRecords



awbrownjr
7 Mar 2012, 1:27 PM
I'm having a hard time retrieving my XMLStore's totalRecords property. How can I return the totalCount value to a variable?



<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- (http://iac-int-cp01.tidalsoft.local:8088/RequestCenter/nsapi/serviceitem/SiIPAddress/Usage=UNASSIGNED#) <serviceitem totalCount="0" recordSize="0" startRow="1" id="96">
<logicName>Name</logicName>

<name>IPAddress</name>

</serviceitem>



getUrl = 'path to xml file';


//==============================================================
// Fields to retrieve data
//==============================================================


var fieldList = [{
name: "IP", mapping: 'serviceItemAttribute[name=IPAddress]'
}];




//==============================================================
// The proxy call
//==============================================================


var proxyAssigned = new Ext.data.HttpProxy({
url: getUrl,
method: 'GET'
});


//==============================================================
// The data store
//==============================================================
var storeAssign = new Ext.data.XmlStore({
autoDestroy: true,
autoLoad: true,
storeId: 'myAssignIP',
proxy: proxyAssigned,
root: "serviceitem",
record: 'serviceItemData',
idPath: 'rowId',
totalRecords: '@totalCount',
fields: fieldList
});

var totalIPRecords = storeAssign.totalRecords;

scottmartin
29 Mar 2012, 9:59 AM
Are you getting a value when you place a watch on storeAssign?

You will need to place the code in a listener on the store so it knows when to check for the value



var storeAssign = new Ext.data.XmlStore({
..
fields: fieldList,
listeners: {
load: function(){
// check total property
}
}
});


Regards,
Scott.