You need to sign in to do that
Don't have an account?
srinivasu
how to render a VF page without buttons using <apex:detail> TAG
Hi,
Is it possible to render a VF page without buttons for eg: Edit,Delete etc using <apex:detail> tag.
I am using apex:detail because i have to display all sections of the detail page as a printable view , but the buttons should not be displayed. Any help will be appreciated..
Thanks and regards
vasu
Thank you Imran...it works perfectly with the following code:
<script>
for(i=0;i<window.document.getElementsByName('edit').length;i++)
{
window.document.getElementsByName('edit')[i].style.display = 'none';
}
for(i=0;i<window.document.getElementsByName('del').length;i++)
{
window.document.getElementsByName('del')[i].style.display = 'none';
}
</script>
All Answers
Add below javascript code on onLoad function
<script>
window.onload = function removeButtons() {
for(i=0;i<window.document.getElementsByName('edit').length;i++
{
window.document.getElementsByName('edit')[i].style.display = 'none';
}
for(i=0;i<window.document.getElementsByName('del').length;i++
{
window.document.getElementsByName('del')[i].style.display = 'none';
}
}
</script>
Hope this will work out for you.
Hi,
You can use style css to hide and show the edit,delete button with apex:detail tag.
<style>
.btn{display:none;}
</style>
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
I'm having this exact same issue.
I have a VF page that I'm using to launch a flow/interview. The flow is navigated by using a built-in Next/Previous button.
Making all css .btn classes hidden as suggested will remove those crucial buttons. It would be ok if I could somehow change the class of those buttons and then hide all the other .btn classes but I'm not sure how to override these.
I also tried the code above that where you're trying to call GetElementsbyName('edit') but that won't fire either.
Here is my page:
If I replace this code block:
with this line:
the code fires successfully, so the problem may be in that block, i'm just not sure what that would be.
Thanks!
hii..thank u so much for the reply...but i am not able to trigger the code for onload...can u plz share the code snippet for using the code in a visualforce page..
Thanks and regards
Vasu
Thank you Imran...it works perfectly with the following code:
<script>
for(i=0;i<window.document.getElementsByName('edit').length;i++)
{
window.document.getElementsByName('edit')[i].style.display = 'none';
}
for(i=0;i<window.document.getElementsByName('del').length;i++)
{
window.document.getElementsByName('del')[i].style.display = 'none';
}
</script>
Srivinas, how did you get this working?
I still can't get the onLoad to fire.
Here is a much simpler page I tried adding an onLoad event to, with the code you got working.
Again, if I replace the block of code you pasted above and replace it with just an alert, it fires.
Hi Jordan,
I am not using onload function;
you can try below code, it works fine; u have to add the detail tag before u call the script.
<apex:page standardController="Account">
<apex:pageMessages />
<apex:detail relatedList="true" />
<script>
<!-- window.onload = function removeButtons() { -->
for(i=0;i<window.document.getElementsByName('edit').length;i++)
{
window.document.getElementsByName('edit')[i].style.display = 'none';
}
for(i=0;i<window.document.getElementsByName('delete').length;i++)
{
window.document.getElementsByName('delete')[i].style.display = 'none';
}
//}
</script>
</apex:page>
Oh! Yes, the order I was calling the code in was ruining it. This works fine. Thank you!
Hi Navatar,
Thanks it works with ur code also...but i needed to display atleast one custom button so i had to go for other option
<style type="text/css">
input.btn[name="clone"]
{
display: none;
}
</style>