Author Topic: Chain select columns  (Read 2091 times)

bruno.anjos

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 4
    • View Profile
Chain select columns
« on: May 25, 2017, 07:49:16 pm »
Hi everyone. I'm trying to make a grid that has chained selects. Both selects have a visible column with the select and the labels and an hidden column with their database id.
What I need is to have the second select showing different options based on what was selected in the first select, or none at all if the first has no options selected.
General example: select1 has the options "bmw" and "audi". Select2 has the options "3 series", "5 series" and "6 series" showing up when "bmw" was selected in select1 and the options "A3", "A4" and "A5" showing up when "audi" was selected. When no options is selected on select1 then select2 should be empty.

I hope that was clear. I tried searching for a way to do this on the API but found nothing. Is there? In case there isn't what would be your advice to go about it?
I was thinking about starting select2 and filling the options depending on select1 when the user edits select2. What do you think?


Thanks in advance for your help!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Chain select columns
« Reply #1 on: May 25, 2017, 09:34:26 pm »
Here is an example of chained/ cascade selects.

https://paramquery.com/pro/demos/cascade_select

Hope it helps.

bruno.anjos

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Chain select columns
« Reply #2 on: May 25, 2017, 09:57:32 pm »
Thanks for your reply!
I had seen this example but it lacked the part where it ties in to database ids (I need a labelIndx and a valueIndx for the second select) and thought the solution might be more complicated than that. Using the example you provided if I use a labelIndx and valueIndx for the regions column and have id/name tuples instead of labels in the regions var and pass that as the options will this work?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Chain select columns
« Reply #3 on: May 26, 2017, 07:03:52 pm »
Yes it would work by replacing region strings with js objects having options in any required format.