+ Start a Discussion
Huy NguyenHuy Nguyen 

display different list view in 1 page

Hi all,

For example . I have 2 recordtype :client and employee and the current page we select View list for each record type it will display the different layout. Is there any way to display 2 view in 1 VF page ? get the ID of view list and display on VF page
ManojjenaManojjena
Hey Ngugen,

Try with below code adjust width as per your page 

<style>
    #leftcolumn { width: 300px; border: 1px solid black; float: left}
    #rightcolumn { width: 300px; border: 1px solid black; float: right}
</style>
</head>
<div id="leftcolumn"><p>first list view </p></div>
<div id="rightcolumn"><p>second list view </p></div>
Huy NguyenHuy Nguyen
I need to get the id of list view and display it
Sampath KumarSampath Kumar
Hi Huy,

You can use controller and write the folloqing query to get the list view.

SELECT Id FROM ListView where name = 'All Open Cases'

Where All Open Cases is the name of the list view.

Please mark this as best answer if it work to make this community clean and re-usable..Try and let me know if it work for you..

Regards
Sampath Kumar Goud
ManojjenaManojjena
Hey Ngugen,

You can use below method to get the related list view Id .Only thing is that you need to pass the Object name and list view name to get the id .
 
Public Id ListViewId(String ObjectName,String listViewLabel){
	Id listViewId;
	String query = 'SELECT Name FROM '+ ObjectName +' LIMIT 1';
	ApexPages.StandardSetController stdCon = new ApexPages.StandardSetController(Database.getQueryLocator(query));
	List<SelectOption> ListViews = stdCon.getListViewOptions();
	for(SelectOption selOpt : ListViews ){
		if(selOpt.getLabel()==listViewLabel){
			listViewId = selOpt.getValue().left(15);
		}
	}
	return listViewId;
}

**If it helps you to solve your problem please mark it as best answer. It will help other to find best answer. 
Huy NguyenHuy Nguyen
Hi Manoj Kumar jena,

I just have one more query. if we have listview id of the object. How we can get the page layout of each id ?