You need to sign in to do that
Don't have an account?
salesforce@14
Add Radio Button in Dynamic search functionality.
Hi All,
I need to add radio button functionality in already implemented dynamic search filter condition. Create 2 radio buttons as AND and OR in VF Page, if i click on AND button , all filter search condition criteria should satisfy and if i click OR button, any one of the filter search condition should satisfy.
Thanks in advance.
I need to add radio button functionality in already implemented dynamic search filter condition. Create 2 radio buttons as AND and OR in VF Page, if i click on AND button , all filter search condition criteria should satisfy and if i click OR button, any one of the filter search condition should satisfy.
Thanks in advance.
Simply create 2 buttons on VF page and bind them with get set variables from page..by default value will be false..onclick change that to true and where you are making dynamic query there you can check the value and add OR or AND conditiona ccordingly..
let me kbiw if you need any code help on this...
Thanks
Sandeep
Hi sandeep sankhla,
can u give me the code for this functionality.
Thanks.
You can refer the code which Sura has mentiuoned and if still you dont get then let me know...also share your code where you have created dynamic query so I can guide you there only ..
Thanks
I tried but i am not getting. This is my part of code.
if(wherecond != '')
{
Fullquery = 'SELECT '+fieldsToDisplay + ' FROM '+objectname+' WHERE '+ wherecond +' ORDER BY NAME LIMIT 100';
system.debug('==Fullquery===='+Fullquery);
masterlist=Database.query(Fullquery);
selectedfields = fieldsToDisplay.split(',');
system.debug('==selectedfields===='+selectedfields);
}
Thanks.
So as Sura mentione dyou just declare a string variable on pageside which will hold the value if it is AND or OR...then simply in you rdosearch method when we are preoaring the string and adding and you add this variable
wherecond =wherecond+' '+returendcondtion+' and '; replace this line with
wherecond =wherecond+' '+returendcondtion+SearchOption;
also replace this line also
wherecond = wherecond.subString(0,wherecond.lastIndexOf(' and '));
with
wherecond = wherecond.subString(0,wherecond.lastIndexOf(SearchOption));
so if SearchOption will haev AND it will append AND else OR it will Append..
please check and let me know if it helps..
thanks
Thank you very much. I try the following code and let you know.
Thanks.
Then you can set the default value from constructor...
in your constructor you can initalize that string to default value which is AND or OR..then it will work..
Thanks
Sandeep
You just need to set the default value for your string..please check and let me know if that helps..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
I did like this.
Public List<SelectOption> getradiobutton()
{
Option = new List<SelectOption>();
Option.add(new SelectOption('AND','AND'));
Option.add(new SelectOption('OR','OR'));
return Option;
}
I passed this string in the page like
<apex:selectOptions value="{!radiobutton}"> </apex:selectOptions>
But i am not getting ouput.
Thanks.
radiobutton = 'AND';
But i dont understand what is the need of this.
Thanks.
You should provide default value ...
Can you paste your entire pade and class code..let me have a look ..
Have you tried what I said..as A best practise we should always initalize all our variables before using so I was asking to initalize
radio = default value in constructor..
If you need default value then you can assign else you can assign blank and if you dont select anything it will not add any filter in your query..
Both the cases you can do..initalize it to blank
radio = "";
Thanks
I tried like this string radio=''; in constructor but i am not getting.
Thanks.
you need to check this string and then make the queru
if(wherecond != '' && radio != '')
{
Fullquery = 'SELECT '+fieldsToDisplay + ' FROM '+objectname+' WHERE '+ wherecond +' ORDER BY NAME LIMIT 100';
system.debug('==Fullquery===='+Fullquery);
masterlist=Database.query(Fullquery);
selectedfields = fieldsToDisplay.split(',');
system.debug('==selectedfields===='+selectedfields);
}
else
{
Fullquery = 'SELECT '+fieldsToDisplay + ' FROM '+objectname+' ORDER BY NAME LIMIT 100';
system.debug('==Fullquery===='+Fullquery);
masterlist=Database.query(Fullquery);
selectedfields = fieldsToDisplay.split(',');
system.debug('==selectedfields===='+selectedfields);
}
if that is blank then no condition ..
Please add this else block and blank check in if condition and let me know if it helps..
Thanks,
Sandeep