Opened 12 years ago

Closed 11 years ago

#11215 closed defect (invalid)

dijit.form._FormSelectWidget ._setValueAttr Will Not Always Work When Using a Store (int values!)

Reported by: oakbehringer Owned by: Douglas Hays
Priority: high Milestone: 1.7
Component: Dijit - Form Version: 1.4.1
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

This problem is in the code for dijit.form._FormSelectWidget, but I found it using dojox.form.CheckedMutliSelect.

When you have dojox.form.CheckedMultiSelect attached to a datastore that returns integer values which become the value field for the multiselect's options, it becomes impossible to set the value for the checked multiselect. Here's why:


289 dojo.forEach(newValue, function(i, idx){
290 if(!dojo.isObject(i)){
291 i = i + "";
292 }
293 if(typeof i === "string"){
294 newValue[idx] = dojo.filter(opts, function(node){
295 return node.value === i;
296 })[0] || {value: "", label: ""};
297 }
298 }, this);

Line 291 casts the new value(s) to a string, while on line 295 it type-sensitive compares the new values to the option values. If the option values are integers, it becomes impossible to set the values.

This code is pasted from 1.4.1, but looking that the nightly build revealed that it is still pervasive.

Change History (3)

comment:1 Changed 12 years ago by bill

Description: modified (diff)
Milestone: tbd1.7

That is weird, I'm not sure why the code is casting to a string or why it's doing the triple === instead of the double ==.

Hmm, looks like there are no automated tests for MultiSelect at all :-(, so I'd like to have those before changing the code.

comment:2 Changed 11 years ago by bill

Component: DijitDijit - Form
Owner: set to Douglas Hays

See also #11545, #12434. dijit.form.Select seems to demand that "value" be a string, not an integer, since when it sees integers it treats them as indexes (indicating nth child) rather than values.

comment:3 Changed 11 years ago by Douglas Hays

Resolution: invalid
Status: newclosed

Bill has decided to keep numeric values reserved for indexing the options array.

Note: See TracTickets for help on using tickets.