You need to sign in to do that
Don't have an account?

Dispaly Alpha bar navigation on Visualforce page for easy jump to pages
Hi
I have simple requirement, I need to disaplay a document list in alpha order and have an alpha bar navigation to easily jump to pages on Visualforce page(Similar to apex class/ visualforce list page which displays the list of class and on click of specific character like "C" or "D" or any other char it display result based on the charecter clicked) I need a soultion something like that any suggestion is highly appricated.
Thanks in Advance.
Hi,
Please find below suggestion. It may help you
create a map<string, string>(mapAlpha) and populate values from A to Z in the constructor
Use the same map on the page using repeat tag and commandlink.
<apex:repeat value="{!mapAlpha}" var="alpha">
<apex:commandLink value="{!alpha}" action="{!refresh}">
<apex:param name="alpha" value="{!alpha}" assignTo="{!passingString}"/>
</apex:commandLink>
</apex:repeat>
Pass value using param attribute to the controller method, where you query
public PageReference refresh(){
....Select fieldName_1, fieldName_2 ... from some_Object where Field_Name.left(1).equalsIgnoreCase(passingString)
}
Hi,
Please go through this sample code. Hope that is very useful for you
Visual Force:
your solution worked perfectly for me, though I have to write tons of lines of code.
Hi Dim,
When I am trying with your method, every thing is fine but in my passingString I am getting value as 'A |' , this | is getting populated with every other Character or alpha word I am clicking I have tried to remove it using replace method that but even tough this character(' |') is not getting removed. here is what I am trying to do. please help me out where I am doing mistake:
<apex:repeat value="{!mapAlpha}" var="alpha">
<apex:commandLink value="{!alpha}" action="{!refresh}" style="font-size:10px; text-align:right;color:red;" >
<apex:param name="alpha" value="{!alpha}" assignTo="{!passingString}"/>
</apex:commandLink>
</apex:repeat>
Controller :
public String[] getmapAlpha() {
return new String[]{'A |',' B |',' C |',' D |',' E |',' F |',' G |',' H |',' I |' ...................,'Z |'};
}
public PageReference refresh() {
system.debug('**PassedStg'+ passingString);
string newString = passingString;
system.debug('newValue'+newString);
string word = newString.remove('|');
system.debug('**reChar'+ word );
lstProd= [select Name,Category__c,id,ProductCode from product2 where Name like :'%'+word+'%'];
system.debug('listView'+lstProd);
return null;
}
I dont know why I am getting | after every alphabet. Please help out.
Thanks and Regards,
Hi Amit,
Use getter setter for the map
public Map<String, String> mapAlpha{get; set;}
Populate the map as shown below( which I did in constructor):
mapAlpha= new Map<String, String>{
'A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E',
'F' => 'F', 'G' => 'G', 'H' => 'H', 'I' => 'I', 'J' => 'J',
'K' => 'K', 'L' => 'L', 'M' => 'M', 'N' => 'N', 'O' => 'O',
'P' => 'P', 'Q' => 'Q', 'R' => 'R', 'S' => 'S', 'T' => 'T',
'U' => 'U', 'V' => 'V', 'W' => 'W', 'X' => 'X', 'Y' => 'Y',
'Z' => 'Z'
};
***************************************
page:
<apex:repeat value="{!mapAlpha}" var="alpha">
<apex:commandLink value="{!alpha}" action="{!refresh}">
<apex:param name="alpha" value="{!alpha}" assignTo="{!passingString}"/>
</apex:commandLink>
<apex:outputText > | </apex:outputText>
</apex:repeat>