0

I am using Visualforce data table to display account records.I am also using alphabetical filter to display account records based on the alphabet selected .while doing so if I press "A" it results in account starting with "A" properly, but if I press b it displays accounts with "a" and "b" and c with "a","b" and "c". What could be the issue?. How to rectify it?

enter image description here

In Visualforce Page:

    <apex:repeat value="{!alphabets}" var="a">
<apex:commandLink value="{!a}"  action="{!Alphabetorder}"  style="{!if($CurrentPage.parameters.alpha=a,'font-weight:bold','')}"  >
<apex:param name="alpha" value="{!a}"/>
</apex:commandLink>

&nbsp;|&nbsp;
 </apex:repeat>

In controller:

 string s1;
   if(apexpages.currentpage().getparameters().get('alpha') == 'All')
       s1='%';
   else
       s1= apexpages.currentpage().getparameters().get('alpha')+'%';
       system.debug('alphabet ordering'+s1);

And added the s1 in query as name like :s1

5
  • Is this the view of when you select by the letter 'A', because it is still showing reults for 'B'. Commented Aug 19, 2016 at 13:08
  • This is when I selected A first then b.It is showing the value of previously selected 'A' value along with 'B' Commented Aug 19, 2016 at 13:14
  • So you are not trying to filter by, but instead you want a multiple sort by on one column? Normally when you do something like this you multi-sort by different columns, not values within the same column. Commented Aug 19, 2016 at 13:21
  • Can you post the code where you set the filter? Commented Aug 19, 2016 at 13:59
  • I have updated the question Commented Aug 19, 2016 at 14:28

1 Answer 1

0

You need to use a LIKE operator here.

You will be having a query inside a class which is fetching Account records.

The sample code to filter Account will be,

String charValue = 'A'; // capture the character clicked by an end user
String inputStr = charValue + '%';
List<Account> accountList = [Select Id , Name, BillingCity from Account where Name LIKE : inputStr];
System.debug('New Account List :: '+accountList);
2
  • This is how I am using already Commented Aug 19, 2016 at 13:14
  • I have updated the question Commented Aug 19, 2016 at 14:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.