
// for active and deactive page naviagator
public Boolean firstOff{set;get;} // previous part
public Boolean lastOff{set;get;} // next part
public Integer pageNumber{set;get;}
Integer listSize; // for total contact size
public integer TotalPage{get;set;}
public integer offsetval;
public integer limitval;
public OrgUserHierarchy(){
TotalPage = 0;
listSize = 0;
firstOff = false;
pageNumber = 1;
offsetval = 0;
limitval = 10;
this.asm = new List<ObjectStructureMap>{};
asmList = new List<ObjectStructureMap>();
this.masm = new Map<String, ObjectStructureMap>{};
this.maxLevel = new List<Integer>{};
selectedUser = '';
getObjectStructure();
}
public List<userwrap> getUserList()
{
lstWrap = new list<userwrap>();
for(user obj:[select name,profile.name,email,isActive from user limit:limitval offset:offsetval]){
userwrap objwrap = new userwrap();
objwrap.user = obj;
objwrap.isSelected = false;
if(obj.isActive){
objwrap.status = 'Active';
}else{
objwrap.status = 'In-Active';
}
objwrap.sNo = lstWrap.size()+1+offsetval;
lstWrap.add(objwrap);
}
list<user> totalRec = [select username,profile.name,email,isActive from user limit 49990];
if(totalRec!=null && totalRec.size()>0){
if(Math.Mod(totalRec.size(),limitval) == 0)
TotalPage = totalRec.size()/limitval;
else
TotalPage = (totalRec.size()/limitval)+1;
if(totalRec.size() > limitval)
lastOff = true;
else
lastOff = false;
listSize = totalRec.size();
}else{
lastOff = false;
TotalPage = 0;
listSize = 0;
}
//after processing set loadFirstTimeFlag=false
loadFirstTimeFlag = false;
return lstWrap;
// navigate on next page
public void next(){
offsetval += limitval;
if(offsetval>2000){
offsetval = 2000;
}
firstOff = true;
pageNumber = pageNumber+1;
system.debug('===In next page number as : '+pageNumber);
//PrepareUserData();
if(offsetval+limitval >= listsize){
lastOff = false;
}
//
getUserList();
}
// navigate on previous page
public void previous(){
if(offsetval-limitval <= 0){
offsetval = 0;
firstOff = false;
}else{
offsetval -= limitval;
}
lastOff = true;
pageNumber--;
//PrepareUserData();
getUserList();
}
// switch on first page
public void first(){
offsetval = 0;
firstOff = false;
lastOff = true;
pageNumber = 1;
//PrepareUserData();
getUserList();
}
// switch on last page
public void last(){
// set page number of and offset
if(Math.Mod(listSize,limitval) == 0){
offsetval = listSize-limitval;
pageNumber = listSize/limitval;
}
else{
offsetval = (listSize/limitval)*limitval;
pageNumber = (listSize/limitval)+1;
}
if(offsetval>2000){
offsetval = 2000;
}
firstOff = true;
//PrepareUserData();
lastOff = false;
getUserList();
}
1 réponse
Hey Mohan,
Thats a lot of code to go through, besides I think the point of origin for the pagination errors might be at the VF side,
if you want a fancy pagination and table struction i'd suggest use datatablesnet , you will not have to code the pagination functionality
here's the link :http://goo.gl/fPbrS
if our suggestion(s) worked, let us know by marking the answer as "Best Answer" right under the comment.This will help the rest of the community should they have a similar issue in the future. Thank you!
Shiv