PDA

View Full Version : Grid Paging



newb
23 Feb 2009, 11:28 PM
Ext.onReady(function(){

// create the Data Store
var store = new Ext.data.Store({
// load using HTTP
url: '/people/list?format=xml',

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have a "Person" tag
record: 'Person',
id: 'id',
totalRecords: 'TotalResult'
},
[
// set up the fields mapping into the xml doc
// The first needs mapping, the others are very basic
'id','firstname', 'lastname', 'emailaddress'
])
});
store.setDefaultSort('id', 'desc');
// pluggable renders


var pagingBar = new Ext.PagingToolbar({
pageSize: 2,
store: store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display",

items:[
'-', {
pressed: true,
enableToggle:true,
text: 'Show Preview',
cls: 'x-btn-text-icon details',
toggleHandler: function(btn, pressed){
var view = grid.getView();
view.showPreview = pressed;
view.refresh();
}
}]
});



// create the grid
var grid = new Ext.grid.GridPanel({

loadMask: true,
store: store,
columns: [
{header: "SNo", width: 35, dataIndex: 'id',sortable: true},
{header: "First Name", width: 180, dataIndex: 'firstname', sortable: true},
{header: "Last Name", width: 180, dataIndex: 'lastname', sortable: true},
{header: "Email address", width: 200, dataIndex: 'emailaddress', sortable: true}
],

renderTo:'people_grid',
width:800,
height:300,
buttons: [{
text: 'Add People',
handler: function() {
window.location.href = '/people/create';
}
}],
// customize view config
viewConfig: {
forceFit:true,
enableRowBody:true,
showPreview:true,
getRowClass : function(record, rowIndex, p, store){
if(this.showPreview){
p.body = '<p>'+record.data.excerpt+'</p>';
return 'x-grid3-row-expanded';
}
return 'x-grid3-row-collapsed';
}
},

// paging bar on the bottom
bbar: pagingBar
});
// trigger the data store load

grid.render();
store.load({params:{start:0, limit:2}});






});


This is my code to have girid with pagination.
i m very new to Extjs ...
i m trying with Rails.
when see my page it list all the records which i have in my table.
but i have given pagesize 2.
pagination does not works
what would be the problem.pls help

mjlecomte
24 Feb 2009, 5:53 AM
http://extjs.com/learn/Ext_Forum_Help#Code_Tags

http://extjs.com/learn/Ext_Forum_Help#Proper_Posting

mjlecomte
24 Feb 2009, 5:53 AM
http://extjs.com/learn/Ext_FAQ_Grid#Paging.2C_Paging_toolbar.2C_Total_record_count