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
vutukuru balajivutukuru balaji 

how to implement select all function

hi i am implemented a visual force page which displays account object records by reading either name or type or industry of account object record.by selecting the checkbox in headerbar i have to select all the records checkboxes which have been displayed by retriving.and then delete them by clicking delete button .how to implement this functionality of selecting all and deleting.
my Vf page code is:
<apex:page controller="searchquery">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Enter Name"/>
<apex:inputText value="{!aname}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Enter industry"/>
<apex:inputText value="{!aindustry}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Enter type"/>
<apex:inputText value="{!atype}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="submit" action="{!search}" reRender="one"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock id="one">
<apex:pageBlockTable value="{!result}" var="a">
<apex:column >
<apex:facet name="header">
<apex:inputcheckbox label="select"/>
</apex:facet>
<apex:inputCheckbox />
</apex:column>
<apex:column value="{!a.name}"/>
<apex:column value="{!a.industry}"/>
<apex:column value="{!a.type}"/>
<apex:column value="{!a.AccountNumber}"/>
<apex:column value="{!a.AnnualRevenue}"/>
<apex:column value="{!a.Phone}"/>
</apex:pageBlockTable>
<apex:pageblockbuttons location="bottom">
<apex:commandButton value="delete"/>
</apex:pageblockbuttons>
</apex:pageBlock>
</apex:form>
</apex:page>
and my apex class is
public class searchquery
{
public list<Account> result{set;get;}
public string aname{set;get;}
public string aType{set;get;}
public string aindustry{set;get;}
public string rpl{set;get;}
public boolean flag{set;get;}
public searchquery()
{
result=new list<Account>();
selected=false;
}
public void search()
{
rpl='select name,industry,type,AccountNumber,phone,AnnualRevenue from account';
if((aname!=''&&aname!=null)&&(atype!=''&&atype!=null)&&(aindustry!=''&&aindustry!=null))
{
rpl=rpl+' where (industry=:aindustry AND type=:atype AND name=:aname)';
}
else
{
if((aname!=''&&aname!=null)&&(atype!=''&&atype!=null))
{
rpl=rpl+' where (type=:atype AND name=:aname)';
}
else
{
if((atype!=''&&atype!=null)&&(aindustry!=''&&aindustry!=null))
{
rpl=rpl+' where (industry=:aindustry AND type=:atype)';
}
else
{
if((aname!=''&&aname!=null)&&(aindustry!=''&&aindustry!=null))
{
rpl=rpl+' where (industry=:aindustry AND name=:aname)';
}
else
{
if(aname!=''&&aname!=null)
{
rpl=rpl+' where (name=:aname)';
}
else
{
if(atype!=''&&atype!=null)
{
rpl=rpl+' where (type=:atype)';
}
else
{
if(aindustry!=''&&aindustry!=null)
{
rpl=rpl+' where (industry=:aindustry)';
}
}
}
}
}
}
}
result=Database.query(rpl);
}
}
 
sandeep sankhlasandeep sankhla
Hi vutukuru,

You can make use of wrapper class for binding the checkboxes with records and then onclick of the checkboxes you can call one methdo where you will delete all of them..

Let me knwo if you need anything as reference on this to implement..

Thanks,
Sandeep