0% found this document useful (0 votes)
467 views9 pages

Filter Dropdown Fields by Previous Filter - Fabrik

The document discusses setting up cascading dropdown filters in Fabrik. A user is trying to filter a dropdown list of states based on the selected country in the first dropdown, pulling values from the same database table. While some suggestions are provided, the user continues to struggle getting it working correctly. Setting up related database tables and using the cascading dropdown plugin are recommended to filter the second dropdown dynamically based on the first selection.

Uploaded by

AhmadEsty Tohir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
467 views9 pages

Filter Dropdown Fields by Previous Filter - Fabrik

The document discusses setting up cascading dropdown filters in Fabrik. A user is trying to filter a dropdown list of states based on the selected country in the first dropdown, pulling values from the same database table. While some suggestions are provided, the user continues to struggle getting it working correctly. Setting up related database tables and using the cascading dropdown plugin are recommended to filter the second dropdown dynamically based on the first selection.

Uploaded by

AhmadEsty Tohir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

1/28/2016

Filter dropdown fields by previous filter | Fabrik

Login

Home

Forums

SearchForums

Wiki

Members

RecentPosts

Home Forums Fabrik2.x FeatureRequests Com pleted

Filterdropdownfieldsbypreviousfilter
1

Next>

dantheafrican
New Member

HiNotsureifthisisalreadypossible,butitwouldsurebeuseful
BasicallyIhaveatablewithsomesearchfiltersatthetop.WhatIamlookingtodoisfilterwhatisdisplayedina
dropdownbasedonwhatoptionwaspreviouslyselected.
Forexampleifthefirstdropdownlistscountriesandthesecondonelistsstates,thenifsomeoneselectsUSAin
thefirstdropdown,itwillonlylistUSstatesinthesecondone(orfieldsthathavecorrespondingrowsinthe
database)asopposedtohowitcurrentlyworkswhereeachdropdownjustlistsallavailableoptionsallthetime.
Ideallythisshouldbedynamicsoitwouldjustlookforallstateswheretherearerowsinthedatabasetoavoid
havingtolistallstates
Cheers
Nov26,2008

dantheafrican
New Member

Right,aftersomemoreinvestigationIseethatthisispossible.Ihaveinstalledthecascadingdropdownandhave
beentryingtogetitworking.IkeepgettingSQLerrorsatthetopofthetablepagenomatterwhatcombination
ofvaluesIsetforthecascadingdropdown.
BasicallyIhaveonereallybigtableinthedatabasethatcontainsvaluesforalotofprojects.Ihavethetableset
tofilterbycountryfirst(bypullingupalltheuniquecountryvaluesfromthedatabase),Iwouldthenlikethe
secondfiltertolookinthesametableforallstatesthathavecorrespondingcountryvaluestotheoneinitially
selectedandthenlistthestatesinthedropdown.
http://fabrikar.com/forums/index.php?threads/filter-dropdown-fields-by-previous-filter.8615/

1/10

1/28/2016

Filter dropdown fields by previous filter | Fabrik

I'vesetthelabelfieldinthecascadingdropdownto"states"IDto"id"andKeyto"country"(andeveryother
conceivablecombination)thewatchelementissettotheIDofthecountryelement(848)
Itlookslikemostoftheotherthreadspertainingtothisissuehavemultipledatabasetablesthatarebeingjoined.
IhavetriedcreatinganewFabriktabletolinkto,butthathasn'tworkedeither.GuessIhaven'tstructuredthe
databaseinthemostefficientwaybutitcertainlylookslikeitshouldbepossiblebasedonwhatothershave
accomplishedintheforums
Thanks!
Nov26,2008

cheesegrits
SupportGopher
StaffMember

I'mnotsureifitwillworktryingtousethesametable,butonethingyouaredoingwrongisthe"watched
element"needstobetheelementName,nottheID.
hugh

Nov27,2008

dantheafrican
New Member

Thanksfortheadvice,I'vechangedthewatchedelementtotheelementname(perhapschangethemouseover
helpforthisfieldasitsays"theelementsidtowatch")
JusttoclarifywhetherthisisactuallypossiblewhatshouldIselectunderID?wouldthisbetheactualtablesID
column,orthecountry/statecolumns?...orsomethingelse
IalsoassumeIdon'thavetoinsertanythingintothe"wherequery"asthesqlisbeingbuiltbasedontheprevious
info.
Ifitsatallpossibletobuildasqlquerymanuallyitshouldn'tbetoohardformetodoitjustnotsurehowto
actuallylinkittothedropdowns
Thanks
http://fabrikar.com/forums/index.php?threads/filter-dropdown-fields-by-previous-filter.8615/

2/10

1/28/2016

Filter dropdown fields by previous filter | Fabrik

Nov27,2008

cheesegrits
SupportGopher
StaffMember

The"where"isoptional,andyoudon'tneedit.
You'dusuallyselectthepeimraykeyofthetableastheID,andsomedescriptivefieldasthelabel.
There'sseveraldetaileddescriptionsofhowthecascadeisconfiguredintheforumsasearchfor'cascading
dropdowncitiesstates'wouldprobablyyieldsomeresults.
hugh
Nov28,2008

cypherinfo
Member

dantheafricansaid:

Thanksfortheadvice,I'vechangedthewatchedelementtotheelementname(perhapschangethemouseoverhelpforthisfieldasit
says"theelementsidtowatch")
JusttoclarifywhetherthisisactuallypossiblewhatshouldIselectunderID?wouldthisbetheactualtablesIDcolumn,orthe
country/statecolumns?...orsomethingelse
IalsoassumeIdon'thavetoinsertanythingintothe"wherequery"asthesqlisbeingbuiltbasedonthepreviousinfo.
Ifitsatallpossibletobuildasqlquerymanuallyitshouldn'tbetoohardformetodoitjustnotsurehowtoactuallylinkittothe
dropdowns

Whataboutthefinalresult?Didyousucceed?IfyesIwouldliketoknowhowdidyoubuild(stepbystep)your
cascadingmen.
Thankyou.

Cypherinfo.
Aug4,2009

QfwfQ
New Member

http://fabrikar.com/forums/index.php?threads/filter-dropdown-fields-by-previous-filter.8615/

3/10

1/28/2016

Filter dropdown fields by previous filter | Fabrik

Hello,
I'mcurioustoknowaboutittoo.

QfwfQ
Aug6,2009

sybn
New Member

cypherinfosaid:

Whataboutthefinalresult?Didyousucceed?IfyesIwouldliketoknowhowdidyoubuild(stepbystep)yourcascadingmen.
Thankyou.

Cypherinfo.

Iamcurious,too.Isn'tthereatutorialaboutthisissue?
Sep10,2009

rima
New Member

Iwouldliketoknowhowtomakedynamicdropdownmenus,ItriedtheCascadingStylesheetbutcantseemto
getitworking.
IwantusertopickacarBrandandthantheType,shouldbethathardIguesbutIdontknowanythingabout
codingorthatstuff
Sep17,2009

cheesegrits
SupportGopher
StaffMember

Haveyoulookedthroughthetutorialsandthedemositeforexamples?

http://fabrikar.com/forums/index.php?threads/filter-dropdown-fields-by-previous-filter.8615/

4/10

1/28/2016

Filter dropdown fields by previous filter | Fabrik

hugh

Sep18,2009

rima
New Member

yeaIdid,butisntworkingforme
Itsveryconfusing,canyoumakedropdownsearchon2elementswheninthesamedatabasetable?

Sep21,2009

rob
Administrator
StaffMember

Itsveryconfusing,canyoumakedropdownsearchon2elementswheninthesamedatabasetable?

yesyoucan.
Letstakethisinsmallstepsusingyourcarbrandexample
Youshouldhaveatablecalled'car_brands'
itshouldhavetwofields:
fabrik_internal_id
label
fabrik_internal_idisthetable'sprimarykeyandshouldbeautoincrementing
Thenintheformwhereyouwanttoshowadropdownofcarbrands,setupadatabasejoinelementwhichpoints
tothe'car_brands'table.Itssettingsshouldbesetto:
connection:sitedatabase
table:car_brands
key:fabrik_internal_id
label:label
http://fabrikar.com/forums/index.php?threads/filter-dropdown-fields-by-previous-filter.8615/

5/10

1/28/2016

Filter dropdown fields by previous filter | Fabrik

ensureitspublished,andsaveit
thencheckyourform,itshouldnowhaveadropdownthatcontainsalistofalltherecordsinthe'car_brands'
table
Onceyou'vegotthatworkingreportbackhereandI'lltalkyouthroughthesecondstep
Rob
Sep22,2009
1personlikesthis.

rima
New Member

Itshowsadropdownbutitdoesntworkasasearchformydatabase.
Ihaveadatabasewithcarradiators,ithasthingsasbrand,type,motortypeetc.butthisdoesntgivemea
dropdownsearchforthattable.
Idontseehowthiswillbeusefull?
Sep22,2009

rob
Administrator
StaffMember

okyoushouldhaveperhapssaidthatyouwantedtofiltertheresults,aswhilsttheoriginalpostwasaboutthat
therestofthedisssiondivergedawayfromthat!
Sowhatyouwant,ifIhaveunderstood,istohaveafilteratthetopofyourtablethatfiltersthelistofrecords
thattheusersees?
Ifsosettheelement'sfilteroptionto'dropdown'.Thisoptioncanbefoundundertheelement'stablesettingstab
Ifitsnotthatthenpleasetakeastepbackandfullyexplainwhatyouwantasitshardtosecondguesspeople
sometimes8)
Sep22,2009

rima
New Member

http://fabrikar.com/forums/index.php?threads/filter-dropdown-fields-by-previous-filter.8615/

6/10

1/28/2016

Filter dropdown fields by previous filter | Fabrik

ImsorryIwasntclearbefore,Iwilltrytoexplain.
Iwantadropdownsearch.Souserscanpickthebrand,forexampleBMWandafterthatIwouldlikea
dynamicresultsinthe2nddropdown,sopeoplecanpickthetype,forexample320.
AfterthattheresultswillonlyshowallBMW320's
Iwasntabletomakethe2ndsearchdynamic,itshowsalltypesforallbrands.
Ihopeyouunderstand8)
Sep22,2009

rob
Administrator
StaffMember

oksoIpresumeyouhavegotthefirstdatabasejoinelementworkingnowasatablefilter.
Sothenextstepistocreateacascadingdropdown(CDD)elementthiselement'observes'thedatabasejoin
element(your'car_brands'element).WhenthatelementchangestheCDDsendsaAJAXrequesttotheserver
togetafilteredlistofresults,inyourcasethatwillmethecartype'sforthatparticularmanufacturer.
*Createatableofcar_types,thisshouldhavethefollowingfields:
fabrik_inte rnal_idtheprimarykey
car_brand_idadatabasejoinelementpointingatthecar_brandtable
labe lafiledtostorethecartype
Thenintheform/tablewhereyouwanttoshowadropdownofcarbrands&cartypes
*Createanewelement
*nameit'car_types'
*settheplugintocascadingdropdown(I'mpresumingyouhavedownloadedandinstalledthispluginfromthe
downloadsection)
giveitthefollowingvalues:
*connection:sitedatabase
*table:car_types
*id:fabrik_internal_id
*label:label
(notehowthoseoptionsareprettysimilartothedatabasejoinweaddedpreviously)
http://fabrikar.com/forums/index.php?threads/filter-dropdown-fields-by-previous-filter.8615/

7/10

1/28/2016

Filter dropdown fields by previous filter | Fabrik

*Watchelement:car_brands(thisisthedatabasejoinweaddedinmypreviousexplaination)
*Foreignkey:car_brand_id
Ensuretheelementissettoshowintableandthatitsfiltertypeissettodropdown
Savetheelement
Sep23,2009

rima
New Member

Cantgetittoworkunfortunatly

robsaid:

car_brand_idadatabasejoinelementpointingatthecar_brandtable

whatisthisbtw?

Evenifthiswillworkitstillnotworkingonmypartsdatabase?
Sep24,2009

rima
New Member

littlekick

Sep28,2009

peamak
Moderator

It'sgonnabehardtobemoreclearthanRobhere...Whereareyounow:didyoutrytosetuptheCascading
dropdown?Doyouhavethecar_typestablesetup?the'car_brand_id'shouldbeadatabasejoinelement
http://fabrikar.com/forums/index.php?threads/filter-dropdown-fields-by-previous-filter.8615/

8/10

1/28/2016

Filter dropdown fields by previous filter | Fabrik

pointingtothetablecar_brandandusingtheidelementofthislasttableasprimarykey.
Thisisbecauseyouhavetotellthecascadingdropdownthelistofvaluestodisplaydependingonthewatch
element(thefirstdropdown).
Sep28,2009

rima
New Member

nevermindittakestolong

Sep29,2009
1

Next>

(Youmustloginorsignuptoreplyhere.)

ShareThisPage
Tw eet

Recom m end Bethefirstofyourfriendstorecommendthis.

Login
UsefulLinks
CreateaFabrikAccount
FabrikWiki
Fabrikongithub
MembersOnlineNow
Total:50(members:0,guests:37,robots:13)

3.1GithubCommits

http://fabrikar.com/forums/index.php?threads/filter-dropdown-fields-by-previous-filter.8615/

9/10

You might also like