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

  • Is this the view of when you select by the letter 'A', because it is still showing reults for 'B'. – Jesse Milburn Aug 19 '16 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' – Priyalakshmi Aug 19 '16 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. – Jesse Milburn Aug 19 '16 at 13:21
  • Can you post the code where you set the filter? – dBeltowski Aug 19 '16 at 13:59
  • I have updated the question – Priyalakshmi Aug 19 '16 at 14:28
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);
  • This is how I am using already – Priyalakshmi Aug 19 '16 at 13:14
  • I have updated the question – Priyalakshmi Aug 19 '16 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.