function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bobby7bobby7 

How can i hide "Recentley viewed cases" in list view when i am developing a VF page using any java script.

I want to remove this highlighted one "Recently viewed cases" from that drop down when i am using apex:listViews

User-added image

Best Answer chosen by bobby7
bobby7bobby7
Hi Caleb,
               I am done with this code. This is working fine for me. I had included some Javascript in below page which is highlighted. That makes my result very easy.


<apex:page showHeader="true" tabstyle="Case" id="thePg">
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/versioning.css" />  
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/extended.css" />
<style>
.actionColumn{ display: none; visibility:hidden;}
</style>

<apex:sectionheader title="Home" subtitle="My Support Cases" />
This is the replacement page for the user's support cases.

<br></br>
<br></br>

<apex:listViews type="case" id="lstView">
        <apex:facet name="header">&nbsp;</apex:facet>
    </apex:listViews>

<apex:enhancedList listid="00B90000003QAdm" customizable="false" rowsPerPage="25" rendered="true" height="600" />



<!------

<apex:ListViews Id="PortalMyCases" rendered="true" type="Case">
        <apex:facet name="header"><br></br>This is the header<br></br><br></br></apex:facet>
        <apex:facet name="footer">This is the footer</apex:facet>
    </apex:listViews>
----->
   
    <script>
  var listVal = document.getElementById('{!$component.lstView}:fcf');
  console.log(listVal);
  if( listVal )
  {
   var options = listVal.options;
   for(i=0; i<options.length;i++)
   {
    console.log(options[i]);
    if( options[i].text == 'Recently Viewed Cases' )
    options[i].remove();
   }
  }
</script>

  
</apex:page>

All Answers

Caleb SidelCaleb Sidel
Enhanced List views let you specify via Id which list view you want to display https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_enhancedList.htm while this is helpful the examples all show using the Id of the list view itself - which of course is problematic if you want users to be able to dynamically create list views and you simply don't want to show Recently Viewed Items. But it could give you a good starting point, you'd have to figure out how to generate your pick list of list views either hard coding the ids or reading the metadata for the tab to get the ids.

Anyway, here's an example of enhanced list views in action http://salesforcetutorials.wordpress.com/2012/02/01/enhanced-list-views-on-a-visualforce-page/

You mentioned Javascript you could try either using something like GreaseMonkey and when the standard page renders rip out that pick list value. You could add the JS to your Enhanced List View VF page which rips out the value from the pick list post render, or you could try some JavaScript injections - render the custom left nav on every page and then in there have the JS that rips out the value. Seems like a lot of work, but if you're handing with JS and you don't mind screenscraping/manipulating the HTML post-render it's possible. Of course Salesforce doesn't support anything like this so you may have to re-write between upgrades/versions.

Good luck!


bobby7bobby7
Hi Caleb,
               I am done with this code. This is working fine for me. I had included some Javascript in below page which is highlighted. That makes my result very easy.


<apex:page showHeader="true" tabstyle="Case" id="thePg">
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/versioning.css" />  
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/extended.css" />
<style>
.actionColumn{ display: none; visibility:hidden;}
</style>

<apex:sectionheader title="Home" subtitle="My Support Cases" />
This is the replacement page for the user's support cases.

<br></br>
<br></br>

<apex:listViews type="case" id="lstView">
        <apex:facet name="header">&nbsp;</apex:facet>
    </apex:listViews>

<apex:enhancedList listid="00B90000003QAdm" customizable="false" rowsPerPage="25" rendered="true" height="600" />



<!------

<apex:ListViews Id="PortalMyCases" rendered="true" type="Case">
        <apex:facet name="header"><br></br>This is the header<br></br><br></br></apex:facet>
        <apex:facet name="footer">This is the footer</apex:facet>
    </apex:listViews>
----->
   
    <script>
  var listVal = document.getElementById('{!$component.lstView}:fcf');
  console.log(listVal);
  if( listVal )
  {
   var options = listVal.options;
   for(i=0; i<options.length;i++)
   {
    console.log(options[i]);
    if( options[i].text == 'Recently Viewed Cases' )
    options[i].remove();
   }
  }
</script>

  
</apex:page>
This was selected as the best answer