View

Wednesday, May 1, 2013

Apex Coding on DATA TABLE DELETE CONTROLLER/ DATA TABLE DELETE PAGE .....

--------------------------DATA TABLE DELETE CONTROLLER----------------------------------


public class DataTableDelete {
public List<Talend__c> leas { get; set; }

   //used to get a hold of the account record selected for deletion
   public string SelectedtalendId { get; set; }
 
   public DataTableDelete() {
       //load account data into our DataTable
       LoadData();
   }
 
   private void LoadData()
   {
     
       leas = [Select t.Id,t.Name__c,t.Phone__c,t.Company__c from Talend__c t];
   }
 
   public void DeleteLead()
   {
      // if for any reason we are missing the reference
      if (SelectedtalendId== null)
      {
         return;
      }
      // find the account record within the collection
      Talend__c tobeDeleted = null;
      for(Talend__c t : leas)
       if (t.Id == SelectedtalendId)
       {
          tobeDeleted = t;
          break;
       }
     
      //if account record found delete it
      if (tobeDeleted != null) {
       Delete tobeDeleted;
      }
   
      //refresh the data
      LoadData();
   }
   
 
  }

----------------------------DATA TABLE DELETE PAGE-----------------------------------------


<apex:page controller="DataTableDelete">
<script>
var newWin=null;
    function openLookupPopup(id)
    {
        alert(id);
        var url="/apex/talend1?idfield="+ id;
        newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
        if (window.focus)
        {
            newWin.focus();
        }
        return false;
    }
    function addopenLookupPopup()
    {
       
        var url="/apex/addtalend";
        newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
        if (window.focus)
        {
            newWin.focus();
        }
        return false;
    }
</script>
<apex:sectionHeader title="Talend Edit" subtitle="Talend"/>
<apex:form id="form" >
<apex:pageBlock title="Talend" id="pb1">
<apex:pageblockButtons location="Top">
     <apex:CommandButton value="Add"   onclick="addopenLookupPopup()"/>
</apex:pageblockButtons>
  <apex:pageMessages ></apex:pageMessages>
  <apex:pageBlockTable value="{!leas}" var="row">
  <apex:column >
  <apex:facet name="header">Name</apex:facet>
  <apex:outputLink value="/{!row.Id}" target="_blank">{!row.Name__c}</apex:outputLink>
  </apex:column>
     <apex:column value="{!row.Phone__c}"/>
     <apex:column value="{!row.Company__c}"/>
     <apex:column headerValue="Action">
   
      <a href="#" onclick="openLookupPopup('{!row.Id}'); return true"> <img src="" alt="Edit"/></a>&nbsp;&nbsp;
      <a href="javascript:if (window.confirm('Are you sure?')) DeleteLead('{!row.Id}');" style="font-weight:bold">Del</a>
     </apex:column>
   
  </apex:pageBlockTable>
</apex:pageBlock>
<apex:actionFunction action="{!DeleteLead}" name="DeleteLead" reRender="form" >
   <apex:param name="leadid" value="" assignTo="{!SelectedtalendId}"/>
</apex:actionFunction>
</apex:form>
</apex:page>


No comments:

Post a Comment

Share your Comments .............