How to remove and Delete row from PageBlock table on VF page

<apex:page controller="Classname" sidebar="false">
   <style>
.Processing
{
position: fixed;
background: url('/img/loading32.gif');
background-repeat: no-repeat;
background-position: center;

width: 100%;
height: 100%;
z-index: 1004;
left: 0%;
top: 0%;
}
</style>

<apex:Form id="frmId">
<apex:actionstatus id="statusProcessing" startstyleclass="Processing"></apex:actionstatus>
<apex:pageBlock id="blockTD">
<apex:variable var="delrowNumber" value="{!0}"/> 
<apex:pageBlockTable value="{!lstofData}" var="objTB">
<apex:column headerValue="Action">
<apex:commandLink value="Del" style="color:red" action="{!delRow}" immediate="true" reRender="blockTD" status="statusProcessing" >
<apex:param name="ItemIDDel"  assignTo="{!ItemIDDel}" value="{!delrowNumber}"/>
</apex:commandLink>
<apex:variable var="delrowNumber" value="{!delrowNumber+1}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageblock>

<apex:pageBlock id="PBID">
<apex:variable var="rowNumber" value="{!0}"/> 
<apex:pageBlockTable value="{!lstofwrapperClass}" var="objWrp">
<apex:column headerValue="Action">
<apex:commandLink value="Remove" style="color:blue" action="{!RemoveRow}" immediate="true" reRender="PBID"  status="statusProcessing">
<apex:param name="ItemID"  assignTo="{!ItemID}" value="{!rowNumber}"/>
</apex:commandLink>
<apex:variable var="rowNumber" value="{!rowNumber+1}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock> 

</apex:Form>  
</apex:page>





Class Code


public Class Classname

{
    public void RemoveRow()
    {       
        Integer indexVal = Integer.valueof(system.currentpagereference().getparameters().get('ItemID'));

        lstofwrapperClass.remove(indexVal); 
    }    

    Public objectName del;
    public void delRow()
    {      
        Integer IDTBD = Integer.valueof(system.currentpagereference().getparameters().get('ItemIDDel'));
        del = lstofdata.remove(IDTBD);
        delete del;      
    }  

}



Comments

Popular Post

Show Hyper Link On Add Error in Salesforce Trigger

Select and Deselect Check Box on Page Block Table in Visual force Using JavaScript

Send SMS Using Batch Class in Salesforce