1

I am trying to do pagination for OrderItems using StandardSetController, however, when I am passing my query in setCon, I am getting following error.

List controllers are not supported for OrderItem.

Here is the code:

public ApexPages.StandardSetController setCon {
  get{
    if(setCon == null){
      size = 10;

      string queryString = 'select Id from OrderItem';
      setCon = new ApexPages.StandardSetController (Database.getQueryLocator(queryString));
      setCon.setPageSize(size);
      noOfRecords = setCon.getResultSize();
    }
    return setCon;
  }set;
}

public void getOrderItems(){
  List<OrderItem> lstOrderItem = new List<OrderItem>();
  for(OrderItem o : (List<OrderItem>)setCon.getRecords())
    lstOrderItem.add(o);
  return lstOrderItem;
}
1

I'm guessing this is down to some of the bespoke funcitonality inculded in order items around saving and discount calculations etc..

I think you're going to have to implement pagination manually, you could either query everything and do paging, or use the SOQL OFFSET keyword to pull different pages of data from the DB.

One other alternative is to send all items through to the page and do it through a jQuery plugin or similar, though you'd want to be sure you're not sending hundreds of records back and forth for performance reasons (this does seem unlikely but it'll depend on the business).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.