You need to sign in to do that
Don't have an account?
Varun99
SOQL query using list index value
Hi,
Am displaying contact names using a list. i put command link on contacts.
my requirement is i want queried records click onwards records.
for ex in my contact 100 records displaying when i click on 50th record i want to queried from this record
onwards.
is it possible using list index value? how?
help me.
Hi Varun99,
If I understand you correctly, you require records of contact object from index that was clicked. To achieve this, one way is to use rowIndex property of a table. You can find it here.
Once clicked on a record row, you can pass on the index value via an action function to your controller and then make effective use of OFFSET clause provided by SOQL. To make you aware, OFFSET clause can accept maximum value of 2000.
Please let me know if this helps.
Hi,
how to use rowindex in my cotroller please chech my code once
<apex:page controller="classcon" sidebar="false" showHeader="false">
<apex:form >
<apex:outputPanel rendered="{!clist}">
<apex:pageBlock >
<apex:dataTable value="{!Categories1}" var="c">
<apex:column headerValue="contacts" >
<apex:commandLink value="{!c.name}" action="{!conlist}" >
<apex:param name="conname" value="{!c.id}" id="aaa"/>
</apex:commandLink>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
<apex:panelGrid columns="2">
<apex:commandLink action="{!previous}" rendered="{!hasprevious1}" ><b>Previous</b></apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasnext1}"><b>Next</b></apex:commandlink>
</apex:panelGrid>
</apex:outputPanel>
<apex:pageBlock rendered="{!cdetail}" >
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="edit" action="{!edit}"/>
<apex:commandButton value="back" action="{!back}"/>
</apex:pageBlockButtons>
<apex:pageblockSection >
<apex:repeat value="{!Categories}" var="aaa">
<apex:param name="conname" value="{!aaa.id}"/>
<apex:outputfield value="{!aaa.lastname}"/>
<apex:outputfield value="{!aaa.phone}"/>
<apex:outputfield value="{!aaa.email}"/>
</apex:repeat>
</apex:pageblockSection>
<apex:panelGrid columns="2">
<apex:commandLink action="{!previous}" ><b>Previous</b></apex:commandlink>
<apex:commandLink action="{!next}" ><b>Next</b></apex:commandlink>
</apex:panelGrid>
</apex:pageBlock>
<apex:pageBlock rendered="{!cedit}" >
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="save" action="{!save}"/>
<apex:commandButton value="back" action="{!back}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:repeat value="{!Categories}" var="ab">
<apex:inputfield value="{!ab.lastname}"/>
<apex:inputfield value="{!ab.phone}"/>
<apex:inputfield value="{!ab.email}"/>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
========================================================
public class classcon
{
public boolean clist {set;get;}
public boolean cdetail{set;get;}
public boolean cedit{set;get;}
public id i;
list<contact> con1=new list<contact>();
contact conlst=new contact();
public classcon()
{
clist=true;
cdetail=false;
cedit=false;
//con5 = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id,name FROM Contact]));
//conlist=[select id,name from contact];
//system.debug('@@@@@@'+conlist);
}
public ApexPages.StandardSetController con {
get{
if(con== null)
{
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select id,lastname,phone,email FROM Contact]));
con.setPageSize(1);
system.debug('++++++++'+con);
}
return con;
}
set;
}
public ApexPages.StandardSetController con5 {
get{
if(con5 == null)
{
con5 = new ApexPages.StandardSetController(Database.getQueryLocator([Select id,lastname,name,phone,email FROM Contact]));
con5.setPageSize(10);
system.debug('++++++++'+con5);
}
return con5;
}
set;
}
public void condetail()
{
clist=false;
cdetail=true;
cedit=false;
//con2=new contact();
//con2=[select id,lastname,name,phone,email from contact where id=:i];
//system.debug('========'+con2);
}
//public contact con2{get;set;}
public void edit()
{
clist=false;
cdetail=false;
cedit=true;
}
public void save()
{
//plist.clear();
clist=false;
cdetail=true;
cedit=false;
//con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, lastname,phone,email FROM Contact ]));
//con.setPageSize(1);
//getCategories();
}
public void conlist()
{
id i=apexpages.currentpage().getparameters().get('conname');
//conlst=new contact();
//conlst=[select id,lastname,phone,email from contact where id=:i];
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id,lastname,phone,email FROM Contact]));
con.setPageSize(1);
clist=false;
cdetail=true;
cedit=false;
}
public void back()
{
clist=true;
cdetail=false;
cedit=false;
//con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, lastname,phone,email FROM Contact ]));
//con.setPageSize(1);
//conlist=[select id,name from contact];
//update conlist;
}
list<contact> plist1=new list<contact>();
public List<contact> getCategories1() {
plist1 = new List<contact>();
if(con5!=null)
for (contact c : (List<contact>)con5.getRecords())
plist1.add(c);
return plist1;
}
public list<contact> getCategories()
{
return con.getrecords();
}
public Boolean hasNext {
get {
return con.getHasNext();
}
set;
}
public Boolean hasPrevious{
get {
return con.getHasPrevious();
}
set;
}
public Boolean hasNext1 {
get {
return con5.getHasNext();
}
set;
}
public Boolean hasPrevious1{
get {
return con5.getHasPrevious();
}
set;
}
public void next()
{
con.next();
con5.next();
system.debug('$$$$$$'+Con5);
}
public void previous()
{
con.previous();
con5.previous();
}
}
Thank yor for reply.