[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 400
  • Last Modified:

Dataset Filtering help

I have a dropdown that contains one set of filtering criteria.  It can be 'all','united states' or 'germany'.    I also have a radio button set that specifies 'tsy','faf','rall'   I would like to add even more nice fitering options to the app in the future.    To this end I have started writing a function that takes the values of these as input and will build a filter string to pass to the datasource.dataset.filter.   I am quite poor at doing this however,   I can concat the values  (or erase an arg if its "all") but putting them all together with the commas in the right place (and not accidentally putting one at the begining of the string or an extra one at the end.)  

Advice?   Code?  Anything ? ;)
0
hibbidiji
Asked:
hibbidiji
  • 4
  • 3
1 Solution
 
hibbidijiAuthor Commented:
Perhaps I can build a stringlist of the vars and do some sort of loop through them?   (something I'm fab at in php but get lost with the delphi indexing system)
0
 
kretzschmarCommented:
your question is not clear.

what do you have (radios and/or combo)?
what is your field you will filter (only one, or different)?

in case of selecting all, just set filtered to false

in case of selecting on from the combo

dataset.filter := 'YourFieldName = '+quotedstr(combobox1.items[combobox1.ItemIndex]);
dataset.filtered := true;

about your radios, don't know what you mean

maybe you could clarify a bit

meikl ;-)
0
 
hibbidijiAuthor Commented:
Here comes the clarification:


I want to be able to filter more than one column at once.

I have a dropdown where the country can be selected, as there might be dozens in the long run.   The radio group has 3 set values.  'tsy','faf' or 'rall'   I actually have a 3rd and a 4th filter option as well.    I would not set the filtered to false because its impossible for there to be NO filter options.   at least the radio group will set one option.  

Lets say I have "usa" selected in the country dropdown, "faf" selected in the radio troup and "r" in another radio group called "mode".   I would like my function to do this:

datasource.dataset.filter := 'country=''usa'',rg1=''faf'',mode=''r''';

however if country is set to "all" (not an actual column value) I would want to NOT set the country in the filter string:

datasource.dataset.filter := 'rg1=''faf'',mode=''r''';

Assuming I have only 4 or 5 possible filters, should I just be doing this longhand instead of trying to automate it too much?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
kretzschmarCommented:
well ok,

now i miss only if it is an AND or OR option of your three filter options

usual you have to concatinate the options with this operater like (in case of AND)

datasource.dataset.filter := 'country=''usa'' and rg1=''faf'' and mode=''r''';


meikl ;-)
0
 
hibbidijiAuthor Commented:
See? this is why I always like your answers... I'm a moron at this and I didnt pay any attention to that.  in this case it will all be AND.
0
 
hibbidijiAuthor Commented:
I will go ahead and do this sucker the long way. thanks
0
 
kretzschmarCommented:
well, good luck,

if you run into problems due your implementation,
just return to this q. i will try to give you further advice then

in the meanwhile i'm glad to helped you

meikl ;-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now