rtucek/vue-query-builder

Is it possible to create components with dynamic values?

Closed this issue · 5 comments

I need to add some custom components but with dynamic values (fill a dropdown with values coming from DB)
is it possible?

thanks!

Basically yes, but your component will have to handle this logic of course.
The query builder just expects that the component reports the selected value via v-model API (see docs).

This is my situation:

  • i've a list of objects (let's call each object 'Survey') and they are shown in a record list (the classic index page)
  • In order to create a Survey, the user land on a form when there are multiple questions and for each of them there is an answer
  • one field is called 'visible if' and your plugin is linked to this field
  • basically the goal is to specify the logic in order to show this line in the record list page (visible if Survey1.Question2 = 3)
  • i'm struggling cause it should be dynamic (today i'm using the Survey object but tomorrow i'll use the Exigence Object)

image that in the form page i import my component dropdown-custom and used it in your plugin. How can i tell to the component 'Hey you need to fill yourself with these questions' ?

Your question is not query-builder specific - it requires a bit more sophisticated knowledge about Vue, though :)

This sample may illustrate what you're looking for. It creates "new/dynamic" components, which fetch values from an API and use vue-select for visualization.

Edit Dynamic dropdown

Totally agree with you :)
Great it does the work!

Thanks for your help!

i've another question...is there any prebuild functions about 'how to consume the logic' ? (if the result of the logic is true/false)

PS.
If you prefer i can open another issue cause it's a totally different question

I guess your question is related to #19, right?

If not, pls open another issue for further discussion 🙏