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
alex_from_parisalex_from_paris 

Which object should use to create a kind of custom list view (with edit and delete link)

Hello

I would like to develop this in Visualforce

 

How can I have clickable link (like edit) : apex:outputLink does not work

<apex:page controller="myExtension">

<apex:pageBlock title="Account">

<apex:pageBlockTable value="{!myaccount}" var="myitem">

<apex:outputLink value="https://cs7.salesforce.com/{!myitem.id}/e">Edit</apex:outputLink>

<apex:column value="{!myitem.Name}"/> <apex:column value="{!myitem.fax}"/>

</apex:pageBlockTable> </apex:pageBlock>

</apex:page>

 

Thanks for your help

Best Answer chosen by Admin (Salesforce Developers) 
Devendra@SFDCDevendra@SFDC

 

Hi alex,

 

"Which object is to use" is depend on which record you need to display in table. From the attached image, the records are belong to Account object. You can create custom list view using vf,apex code for standard as well as for custom objects.

 

You can use below link for Edit and Delete

 

http://salesforcesource.blogspot.com/2009/09/edit-and-delete-command-for-your.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+SalesforceTips+(Salesforce+Tips)

 

Hope this helps.

 

Thanks,

Devendra S

All Answers

Devendra@SFDCDevendra@SFDC

 

Hi alex,

 

"Which object is to use" is depend on which record you need to display in table. From the attached image, the records are belong to Account object. You can create custom list view using vf,apex code for standard as well as for custom objects.

 

You can use below link for Edit and Delete

 

http://salesforcesource.blogspot.com/2009/09/edit-and-delete-command-for-your.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+SalesforceTips+(Salesforce+Tips)

 

Hope this helps.

 

Thanks,

Devendra S

This was selected as the best answer
Sunay - KVP Bus SolnsSunay - KVP Bus Solns

Hi Alex,

 

This is Sunay representing KVP Business Solutions. I have a solution for your query, please go through the following code and this would help you in creating a list view on visual force page with all functions working.

 

<apex:page showHeader="false" sidebar="false">

<div id="listdiv" ><apex:listViews type="Account"/></div>



<script type="text/javascript">
{
try{
var elem = document.getElementsByTagName("*");
var rdiv=null;
var flink=null;
var slink=null;
for(var i = 0; i < elem.length; i++)
{
try{
if(elem[i].className=='withFilter')
{

if(elem[i].firstChild.className=='rolodex')
{
rdiv=elem[i].firstChild;
}
}
if(elem[i].className=='fewerMore')
{

if((elem[i].childNodes[1]!=null))
{
flink=elem[i].childNodes[1];
flink.style.margin="0px 4px 0px 20%";

if(flink.childNodes[0].tagName=='IMG')
flink.removeChild(flink.childNodes[0]);
else
if(flink.childNodes[1].tagName=='IMG')
flink.removeChild(flink.childNodes[1]);

}
if(elem[i].childNodes[3]!=null)
{
slink=elem[i].childNodes[3];
slink.style.margin="0px 4px 0px 4px";

if(slink.childNodes[0].tagName=='IMG')
{ slink.removeChild(slink.childNodes[0]);
}
else
if(slink.childNodes[1].tagName=='IMG')
slink.removeChild(slink.childNodes[1]);
}
elem[i].parentNode.removeChild( elem[i]);
}
if(elem[i].className=='list')
{
elem[i].className ='tablesorter';
elem[i].cellSpacing="1";
}
if(elem[i].className=='headerRow')
{
elem[i].firstChild.colSpan="2";
for(j=0;j<elem[i].cells.length;j++)
{ var ispan=document.createElement("SPAN");
ispan.className="img1";
var ispan1=document.createElement("SPAN");
ispan1.className="img1";
if(elem[i].cells[j].firstChild.childNodes[1]!=null)
{
var link =elem[i].cells[j].firstChild;
var image=elem[i].cells[j].firstChild.childNodes[1];
elem[i].cells[j].removeChild( elem[i].cells[j].firstChild);
elem[i].cells[j].appendChild(ispan);
elem[i].cells[j].appendChild(ispan1);
elem[i].cells[j].childNodes[0].appendChild(link );
elem[i].cells[j].childNodes[1].appendChild( image);
elem[i].cells[j].childNodes[1].style.marginTop="2px";
}
}
}
if(elem[i].className.indexOf("dataRow")!=-1)
{
try
{
var oImg1=document.createElement("img");
oImg1.src='https://na12.salesforce.com/resource/1314355685000/edit';
var oImg2=document.createElement("img");
oImg2.src='https://na12.salesforce.com/resource/1314355726000/cancel';
var inn = elem[i].cells[0].innerHTML;
elem[i].insertCell(0);
elem[i].cells[0].innerHTML=inn;


elem[i].cells[0].removeChild( elem[i].cells[0].lastChild);
elem[i].cells[0].removeChild( elem[i].cells[0].lastChild);

elem[i].cells[1].removeChild( elem[i].cells[1].firstChild);
elem[i].cells[1].removeChild( elem[i].cells[1].firstChild);

elem[i].cells[0].firstChild.removeChild(elem[i].cells[0].firstChild.firstChild);
elem[i].cells[0].firstChild.appendChild(oImg1);

elem[i].cells[1].firstChild.removeChild(elem[i].cells[1].firstChild.firstChild);
elem[i].cells[1].firstChild.appendChild(oImg2);

elem[i].cells[0].width="30px";
elem[i].cells[1].width="30px";
}
catch(err)
{
//alert(err);
}
}
if((elem[i].tagName.toLowerCase() == 'tr')&&(elem[i].className!='headerRow'))
{
try
{
var otd=document.createElement('TR');
otd.setAttribute('width', '100px');
}
catch(err)
{
// alert(err);
}

}
if(elem[i].className=='listHeader')
{
elem[i].firstChild.firstChild.style.display="none";

title= elem[i].firstChild.firstChild.title;
var odiv=document.createElement("DIV");

odiv.className='new_green_container';
odiv.style.marginLeft="43%";
odiv.style.marginBottom="10px";
odiv.innerHTML='\<div class=\"green_button_right\"\>\<div class=\"green_button\"\>\<a id=\"newbtn\" onclick=\"javascript&colon;this.parentNode.parentNode.parentNode.previousSibling.click();\"\>'+title+'\<\/a\> \<\/div\> \<\/div\>';
elem[i].firstChild.appendChild(odiv);
elem[i].style.marginBottom="28px";
}
}
catch(err)
{
//alert(err);

}
}
var tnode=document.createElement("TEXT");
tnode.innerHTML="Records Per Page" ;
var tnode1=document.createElement("TEXT");
tnode1.innerHTML="/" ;
if(flink!=null)
{
rdiv.appendChild(flink);
}
if((flink!=null)&&(slink!=null))
{
rdiv.appendChild(tnode1);
}
if(slink!=null)
{
rdiv.appendChild(slink);
}
if((flink!=null)||(slink!=null))
{
rdiv.appendChild(tnode);
rdiv.style.textAlign="right";
}
}
catch(err)
{

}
}
</script>


</apex:page>

 

 

Hope this helps. If you need any clarification, please feel free to contact.

 

Regards,

Sunay

 

 

alex_from_parisalex_from_paris

Hi Sunay

Thank you for your answer

I was just missing in my code

<apex:column >
<apex:outputLink value="https://cs7.salesforce.com/{!myitem.id}/e">Edit</apex:outputLink>
</apex:column>

Regards

Alex