Sunteți pe pagina 1din 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

S-ar putea să vă placă și