PDA

View Full Version : pagination



javapurna
9 Jan 2013, 1:42 AM
hi ,
i am using extjs 4 . i have a grid that contains pagination tab. i am deleting all all records from page 2 that page shows empty page and hiding next button and previous buttons. user have no chance to move 1 page or 3 page migration.

41181

my code like ...
model
Ext.define('zeekocem.model.User', {
extend: 'Ext.data.Model',
fields: [
{name: 'id',type:'int'},
{name:'name',type:'string'},
{name:'password',type:'string'},
{name:'userId',type:'string'},
{name:'email',type:'string'},
{name:'phoneNumber',type:'int'},
{name:'role',type:'int'},
{name:'allowedNotification',type:'string'},
{name:'allowSystemAlerts',type:'string'}

]
});

Store

Ext.define('zeekocem.store.UserPagination', {
extend: 'Ext.data.Store',
model: 'zeekocem.model.User',
autoLoad: false,
storeId: 'UserPagination',
pageSize:10,

proxy:{
type: 'rest',
url:serviceUrl+'admin-service/users',
reader: {
type: 'json',
root: 'Userpagination.user',
totalProperty: 'Userpagination.totalUsers'
},

afterRequest:function( request, success )
{

},
headers: {
'Content-Type': 'application/json; charset=utf-8'
}


}

});


my rest service method here...
@GET
@Path("/users")
public UserpaginationDTO getUsers(@QueryParam("start") int start, @QueryParam("limit") int limit) throws DomainException , SystemException ;


my dao login here ....
@Override
public UserpaginationDTO getUsers(int start,int limit) throws DomainException, SystemException {
logger.info("Entering in :< [AdminDaoImpl][getUsers] >");
Session session = getSession() ;
List<UserpaginationDTO> usersListCount = new ArrayList<UserpaginationDTO>() ;
UserpaginationDTO userpagination=new UserpaginationDTO();
List<User> usersList = null ;
try{
if(limit== -1){
limit=999999999;
}
usersListCount=session.createCriteria(User.class).list();
usersList = session.createCriteria(User.class).setFirstResult(start).setMaxResults(limit).addOrder(Order.desc("id")).list() ;
userpagination.setUser(usersList);
userpagination.setTotalUsers(usersListCount.size());
}catch(Exception e){
logger.error("Exception Occured",e) ;
}finally{
releaseSession(session) ;
logger.info("Exit from :< [AdminDaoImpl][getUsers] >");
return userpagination;
}
}

please help any one .

mitchellsimoens
11 Jan 2013, 8:40 AM
When you remove the records from the store, you could load the store to get an update in the total count and get things back in line.

javapurna
12 Jan 2013, 12:36 AM
hi ,
i am using extjs 4 . i have a grid that contains pagination tab. i am deleting all all records from page 2 that page shows empty page and hiding next button and previous buttons. user have no chance to move 1 page or 3 page migration.

41181

my code like ...
model
Ext.define('zeekocem.model.User', {
extend: 'Ext.data.Model',
fields: [
{name: 'id',type:'int'},
{name:'name',type:'string'},
{name:'password',type:'string'},
{name:'userId',type:'string'},
{name:'email',type:'string'},
{name:'phoneNumber',type:'int'},
{name:'role',type:'int'},
{name:'allowedNotification',type:'string'},
{name:'allowSystemAlerts',type:'string'}

]
});

Store

Ext.define('zeekocem.store.UserPagination', {
extend: 'Ext.data.Store',
model: 'zeekocem.model.User',
autoLoad: false,
storeId: 'UserPagination',
pageSize:10,

proxy:{
type: 'rest',
url:serviceUrl+'admin-service/users',
reader: {
type: 'json',
root: 'Userpagination.user',
totalProperty: 'Userpagination.totalUsers'
},

afterRequest:function( request, success )
{

},
headers: {
'Content-Type': 'application/json; charset=utf-8'
}


}

});


my rest service method here...
@GET
@Path("/users")
public UserpaginationDTO getUsers(@QueryParam("start") int start, @QueryParam("limit") int limit) throws DomainException , SystemException ;


my dao login here ....
@Override
public UserpaginationDTO getUsers(int start,int limit) throws DomainException, SystemException {
logger.info("Entering in :< [AdminDaoImpl][getUsers] >");
Session session = getSession() ;
List<UserpaginationDTO> usersListCount = new ArrayList<UserpaginationDTO>() ;
UserpaginationDTO userpagination=new UserpaginationDTO();
List<User> usersList = null ;
try{
if(limit== -1){
limit=999999999;
}
usersListCount=session.createCriteria(User.class).list();
usersList = session.createCriteria(User.class).setFirstResult(start).setMaxResults(limit).addOrder(Order.desc("id")).list() ;
userpagination.setUser(usersList);
userpagination.setTotalUsers(usersListCount.size());
}catch(Exception e){
logger.error("Exception Occured",e) ;
}finally{
releaseSession(session) ;
logger.info("Exit from :< [AdminDaoImpl][getUsers] >");
return userpagination;
}
}

please help any one .







thanks so mush Mitchell Simoens