elements.dataprovider.setValueList()

I know it’s a bit specific: I am building a search editor that allows users to select fields, enter criteria and search for that. I can’t use the standard search since not all of my fields a accessible in forms (some show only up as a calculation) and I want my users to be able to save their searches.

Now I have one problem: for some fields I need a value list, especially thos where you choose a value but an ID is delivered. I have a table that contains all searchable fields and there I can store the name of the value list needed. The problem is, that application.getValueListItems only delivers values for custom value lists. I currently see no way how I can dynamically attach a certain value list to one field (my search field) if that value list doesn’t contain fixed values.

There is two possible solutions:

  1. I could have an option to attach a value list to an element of a form: elements.dataprovider.setValueList()

  2. The application.getValueListItems would allow me to attach the definition of value list A to value list B

I think I’d prefer version 1 since that gives me extra options on forms that I now solve in some situations by showing/hiding the same field once with a value list, once without…

Would elements.dataprovider.setValueList() be possible?

Thanks
Patrick

both requests are hard to build, is the only purpose you want to save the query for the user?

that’s sad to hear… No, it is not the only reason, but the main.

I have, for example, a search on zip codes implemented. In Germany, some zips are for a range of streets, others for a city only. That means I can offer a user a value list of streets if available. I do that now by having the field street twice on my form, once with a value list, once without. I then show and hide either version of the field depending on the zip.

But for my search problem I can not see a solution, since I’d had to put all fields with a value list on my form (from all kinds of tables), that’s not practical…

Maybe I am wrong but if part of your issue is that ‘application.getValueListItems’ can only be used on custom valuelists than you might have a solution.

When you know the name of a valuelist you also know the relationship that is the basis for that valuelist. If so, you also know the content of the valuelist and can assign those values to a new valuelist attached to the field with ‘application.setValueListItems’… Or am I missing something?

hmmm. why do I know the relationship used?

But you are right to some point: I need to desribe my fields in a table containing all relevant fields anyway. I could think of defining a “language” that lets me construct any value list. The only thing is then, that I have to take more care in maintaining my field “dictionary”, but that is possible, yes.

You know the relationship since you ‘once’ defined that building the valuelist (I guess). So if you know the name you know what’s in there.

And I agree this way it is not full fledged dynamic but I am not certain if that would be possible anyway. You need to store some data, like you already say, anyway.

patrick:
There is two possible solutions:

  1. I could have an option to attach a value list to an element of a form: elements.dataprovider.setValueList()

  2. The application.getValueListItems would allow me to attach the definition of value list A to value list B

I think I’d prefer version 1 since that gives me extra options on forms that I now solve in some situations by showing/hiding the same field once with a value list, once without…

Hi Patrick,

Here’s what I do in those situations when you want to have a field with a valuelist (sometimes) - and not (sometimes):

  1. Setup the value list a custom values;

  2. Do my own SQL query and save the results in two globals (one for the value to return and one for the value to show);

  3. Now I can use application.setValueList to set it and UN-set it (but still have the values). Also, I can re-run the query (and update the globals) at any time if I want to “refresh” the list.

Hope this helps,

Bob Cusick

yes, I know that, thanks. My problem was, that I only know the name of the value list (not it’s definition) and wanted to attach that to a search field. But I think I can get by using my own construction logic…

Ah, right. Yeah, you’ll have to add some extra data to your definition… but you will create a very flexible solution.

Cool!

Bob