PDA

View Full Version : Alpha2, Paging (TotalCount=100) and not is enable the nav...



franklt69
26 Feb 2007, 4:50 PM
Hi, I have this code, in the grid appear 25 records ok, but in db I have 100, the TotalCount in xml is 100, and paging toolbar don't have enable the button to go the next page what is wrong?
the xml that return is right, I watch it in FF:

<?xml version="1.0" encoding="Windows-1252"?>
<xmlResponse>
<TotalCount>100</TotalCount>
<Rows><ExternalId>8:94</ExternalId>
<Name>Allen, Jermaine K.</Name>
<Address>158-8959 Sed, Av.</Address>
<City>Kennewick</City>
<State>Nunavut</State>
<Zip>B8T 6U7</Zip>
<Phone>(688) 347-2341</Phone>
<Fax>1-845-820-9157</Fax>
<Mobil>1 79 771 8594-3602</Mobil>
<Email>[email protected]</Email>
</Rows>
.......
25 records


var record = Ext.data.Record.create([
{name: 'ExternalId', mapping: 'ExternalId'},
{name: 'Name', mapping: 'Name'},
{name: 'Address', mapping: 'Address'},
{name: 'City', mapping: 'City'},
{name: 'State', mapping: 'State'},
{name: 'Zip', mapping: 'Zip'},
{name: 'Phone', mapping: 'Phone'},
{name: 'Fax', mapping: 'Fax'},
{name: 'Mobil', mapping: 'Mobil'},
{name: 'Email', mapping: 'Email'}
]);
var reader = new Ext.data.XmlReader({
record: 'Rows',
totalProperty: 'TotalCount',
id: 'ExternalId'
}, record);

// create the Data Store
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'HandlerContact.ashx'
}),

// let it know about the reader
reader: reader,
// turn on remote sorting
remoteSort: true
});
ds.setDefaultSort('Name', 'asc');

var cm = new Ext.grid.ColumnModel([
{header: "Name", dataIndex: 'Name', width: 120, sortable: true},
{header: "Address", dataIndex: 'Address', width: 180, sortable: true},
{header: "City", dataIndex: 'City', width: 115, sortable: true},
{header: "State", dataIndex: 'State', width: 100, sortable: true},
{header: "Zip", dataIndex: 'Zip', width: 80, sortable: true},
{header: "Phone", dataIndex: 'Phone', width: 100, sortable: true},
{header: "Fax", dataIndex: 'Fax', width: 100, sortable: true},
{header: "Mobil", dataIndex: 'Mobil', width: 115, sortable: true},
{header: "Email", dataIndex: 'Email', width: 200, sortable: true}
]);

// create the editor grid
var grid = new Ext.grid.Grid('example-grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:false
});

grid.render();

if(!gridPanelContact)
{
innerLayout.beginUpdate();
gridPanelContact = new Ext.GridPanel(grid, {fitToFrame:true, title: 'Contact List', fitToFrame:true});
innerLayout.add('north', gridPanelContact);
innerLayout.endUpdate(true);
}
var gridFoot = grid.getView().getFooterPanel(true);

// add a paging toolbar to the grid's footer
var paging = new Ext.PagingToolbar(gridFoot, ds, {pageSize: 25});
paging.add('-', {
pressed: true,
enableToggle:true,
text: 'Detailed View',
cls: 'x-btn-text-icon details'

});

// create a floating label with display info
var displayInfo = gridFoot.createChild({cls:'paging-info'});
ds.on('load', function(){
//debugger;
var count = ds.getCount();
var msg = count == 0 ?
"No topics to display" :
String.format(
'Displaying topics {0} - {1} of {2}',
paging.cursor+1, paging.cursor+count, ds.getTotalCount()
);
displayInfo.update(msg);
});

// trigger the data store load
ds.load({params:{start:0, limit:25, 'value': value, 'typeSearch': typeSearch, 'operator': operator, 'attribute': attribute, 'condition':condition, 'searchIn': searchIn}});



How I can know if the TotalCount in the xml is read right?

note: I get it in displayInfo Displaying topics 1 - 25 of 25

kind regards
Frank

franklt69
26 Feb 2007, 6:28 PM
Hi watching the examples paging.js here are using proxy: new Ext.data.ScriptTagProxy, I am using Ext.data.HttpProxy I need to know if is there some bug in alpha2 using Ext.data.HttpProxy and paging?

kind regards
Frank

franklt69
27 Feb 2007, 6:25 AM
Hi I found the trouble isn't bug when you are using Ext.data.HttpProxy you have to set it:

var reader = new Ext.data.XmlReader({
record: 'Rows',
totalRecords: 'TotalCount',
id: 'ExternalId'
}, record);


totalRecords not totalProperty

kind regards
Frank

jack.slocum
27 Feb 2007, 8:39 AM
Nice debugging Frank.