Avoiding reverse lookups in dojo 1.2’s dijit.FilteringSelect

Sorry, geeky post ahead, but I’ve been having one of those headache-y times with a piece of code I’ve started to play with, and in Googling, I found enough others who were having the same problems to want to have a concise note of a (possibly hacky) solution.

If you are using dojo, specifically a dijit.FilteringSelect, and are frustrated that, upon selecting an item, your FilteringSelect tries to do a reverse lookup on your label (which may or may not have an easily reversible relationship to the value it represents), then let me point you to “the genesis of a solution”:http://dojotoolkit.org/2007/12/12/dojo-grid-1-1#comment-10358 (mostly to establish credit, since I did have to refine what was presented there for dojo 1.2)

In your javascript, you can do something like:

bc. dojo.declare (“dijitx.form.DLFilteringSelect”, [dijit.form.FilteringSelect], {_setDisplayedValueAttr: function(label, priorityChange) {}});

Then, when you instantiate your widget, whether in markup or code, just use dijitx.form.DLFilteringSelect instead of dijit.form.FilteringSelect.

Now I won’t pretend that this will work perfectly in all circumstances, but I’m using it to apply a filter to a grid, and it seems to work just dandy for me.

Good luck.

Published by

Michael Alan Dorman

Yogi, brigand, programmer, thief, musician, Republican, cook. I leave it to you figure out which ones are accurate.