You need to sign in to do that
Don't have an account?

Adding a list of records to Standardsetcontroller records
Does anybody have an idea of how to add a list of records to a Standardsetcontroller records.
List<Order_c> orderlist1 = this.getordheaderList1(); List<Order_c> orderlist2 =(List<Order__c>)this.totalOrders.getRecords(); orderlist2.addAll(orderlist1);
It is throwing an error as " collection is Read only" while adding the lists.
Does anybody have an idea how to implement that.
I need to show all the list of records on a vf page.
You can use the following code to get the records for standardsetcontroller -
public ClassConstrc(ApexPages.StandardSetController controller) {
ApexPages.StandardSetController cntr = (ApexPages.StandardSetController)controller;
List<order__c> orderList = (List<order__c>)cntr.getRecords();
}
Hi Rajjj,
I don't understand why are you trying to add ANOTHER list of Records to StandardSetController's records list, when you want to display ALL the records on the visual force page.
I can help you if understand your exact requirement, I have worked several scenarios using Standard Set Controller where I created vf pages with pagination control'
@kamini
Here "totalorders" is equal to your "cntr" and i am getting records by using totalorders.getRecords() and then type casting to (List<order__c>)
Like this:
@Shah
I have 2 order lists. one is direct orderlist and other is indirect orderlist.
This line will bring indirect orderlists by querying a different table and then using that list I will query the Order__c. That way I get my indirectoderlist.
The second line will directly get orders from order__c. And that list we get through StandardSetController. These orders are direct orders.
If a company has both direct and indirect orders then we need to show both.
For that purpose i need to add list to otherlist. If it is normal list I can use addAll function. When I am using on this list I am getting collection is Read-only error.
I think we need to use wrapper class. But i havent used them anytime. Can you give me an idea on how to implement my requirement through wrapper class.(I have seen couple of examples but I didn't clearly understood the usage.)
I hope I have explained clearly.
I can explain you wrapper class easily., before that...
why don't you go for a simple solution??
make a SINGLE SOQL query.
i.e.
any further help required..
The business model is different.
For direct orders I can query order__c directly.
For indirect orders I need to query shipto__c(object) and then watever the list i get in shipto__c, I need to query in order__c.
We cannot write in a single query.
If you don't get the scenario, you can say in general whether or not it is possible to add a StandardSetController records type casted to Order__c and other list of Order__c records.
Did you get the resolution here, I have a similar requirement, Please suggest !