Opened 15 years ago

Closed 15 years ago

Last modified 11 years ago

#3346 closed task (wontfix)

Combobox: switch to using getLabel() as default

Reported by: bill Owned by: haysmark
Priority: high Milestone: 0.9beta
Component: Dijit - Form Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

Combobox should call getLabel() by default, to get the text for each entry in the drop down list. Should be able to override the function that generates the DOM for each entry, but the default should be to just use the result returned by getLabel().

Jared has already implemented getLabel() in JsonItemStore?, so JsonItemStore? should have everything you need. In the unit tests there's a data file that serves as an example of how to specify item labels and item identifiers:

Change History (4)

comment:1 Changed 15 years ago by bill

Resolution: wontfix
Status: newclosed

As talked about in the meeting, this doesn't have any value, so we decided not to do it.

comment:2 in reply to:  1 Changed 13 years ago by CnEY

Replying to bill:

As talked about in the meeting, this doesn't have any value, so we decided not to do it.

I am curious as to why this was considered not to be of any value; it seems to me that the reliance on a specific attribute in the data store introduces unnecessary coupling that could be easily avoided by defaulting to getLabel - I mean, that's what getLabel is for after all, isn't it?

In addition to avoiding the aforementioned coupling, allowing use of getLabel could provide far more flexibility. Here is an example. I am writing an implementation of the Read API wherein getLabel will first try the 'description' attribute; if that is blank/undefined, it falls back to 'name', and can further fall back to my identifier attribute. This sort of flexibility seems impossible when restricted to use of the labelAttr field in ComboBox?.

Is there perhaps a complete alternative to the example above, that I have not considered?

comment:3 Changed 13 years ago by bill

Description: modified (diff)

I don't remember a meeting from two years ago, but I suspect it was because the list in the drop down is looked up by searchAttr. In other words, if a user types "bar" into the search box and the drop down list shows "foo" instead of "bar", that's pretty strange. And then you need to think about what happens when the user selects that "foo" entry in the drop down list and tabs away from the ComboBox... does the ComboBox show "foo" in the seach box, or "bar"? Either way seems problematic.

Having said that, there are ways to change what gets displayed in the drop down list, as shown by the custom labelFunc example in test_ComboBox.html.

comment:4 Changed 11 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.