Opened 15 years ago
Closed 14 years ago
#912 closed enhancement (fixed)
[patch][cla] Add ability to set intial values of ComboBox inline
Reported by: | Owned by: | Douglas Hays | |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | Widgets | Version: | 0.3 |
Keywords: | ComboBox inital values | Cc: | [email protected]…, [email protected]… |
Blocked By: | Blocking: |
Description
AFAIK, there is no way of initializing a combo box's values when it is created from an inline div tag. This comes up in the situation where I am displaying a form that already has values (eg. I am editing a database row or something).
Example div tag (note the addition of initValue and initSelectValue):
<div name="cb1" dojoType="combobox"
initValue="label1", initSelectValue="value1" style="width: 300px;"></div>
I'm going to attach a patch for ComboBox? with some code to address this. NOTE: my CLA is in the mail (Name: Aaron M Evans, Email: [email protected]…).
In this patch, I have added a function called setInitialValues that may be called with an initial value for both the comboBoxValue.value and the comboBoxSelectionValue.value. I added properties called initValue and initSelectValue. At the end of fillInTemplate, I added a call to setInitialValues with these values respectively.
The setInitialValues function checks that both the initValue and initSelectValue are non-null and non-empty. If so, it calls setAllValues with these values and creates a result/option node with the values under the optionsListNode. The result/option node is necessary because without it, if you have forceValidOption set to true and the user moves focus to the combobox text input and then moves focus away (without changing the value), the values will get cleared.
Since I was repeating the same code for creating a result node as in openResultList, I took the liberty of moving the common code to a function called createOptionResultNode.
One final modification: I added code to setAllValues to set the selectedResult according to the passed in values. If they are both empty then I set selectedResult to null. I then removed the setting of selectedResult in selectOption since it will now be taken care of by setAllValues. By having this done in setAllValues, when one attaches functions to the setAllValues method (either before or after), they selectedResult and the values of comboBoxValue and comboBoxSelectedValue are consistent.
I don't see an option for attaching a file, but I'm hoping there will be after I submit the bug...
cheers, aaron
Attachments (5)
Change History (18)
Changed 15 years ago by
Attachment: | ComboBox.js added |
---|
comment:1 Changed 15 years ago by
Milestone: | → 0.4 |
---|---|
Owner: | changed from anonymous to alex |
comment:2 Changed 15 years ago by
Cc: | [email protected]… added |
---|---|
Summary: | Add ability to set intial values of ComboBox inline → [patch] Add ability to set intial values of ComboBox inline |
Hi Aaron? Did you get notification that dojo foundation had received your CLA? Also, for patches we need a patch file (you can make one with "svn diff" or menu options from the various SVN clients).
Note that Combobox has changed a lot recently.
comment:3 Changed 14 years ago by
Summary: | [patch] Add ability to set intial values of ComboBox inline → [patch][cla] Add ability to set intial values of ComboBox inline |
---|
cla verified.
comment:4 Changed 14 years ago by
Owner: | changed from alex to tk |
---|
we need to get this patch updated and the changes merged in.
comment:5 Changed 14 years ago by
Cc: | [email protected]… added |
---|---|
Status: | new → assigned |
Aaron,
Could you please update this to work with latest SVN? If possible a .patch or .diff would be nice, but I'm not picky. :)
One thing to note is that ComboBox?.js now resides in /src/widget/ not /src/widget/html/ , the other form widgets should provide good examples on what needs changing.
Thanks for the help on this!
-Karl
comment:6 Changed 14 years ago by
Milestone: | 0.4 → 0.5 |
---|
out of time for 0.4, will make into head just after that.
comment:7 Changed 14 years ago by
Hey guys, sorry, somehow I lost this thread of mail in my gmail so I thought there was nothing happening with this until I checked today.
I don't see where I can attach the patch file to this note, but I'll see if I can after I post this...
comment:8 Changed 14 years ago by
Changed 14 years ago by
Attachment: | Select.patch added |
---|
This Select.patch goes with ComboBox?.patch (patches setAllValues)
comment:9 Changed 14 years ago by
Owner: | changed from tk to bill |
---|---|
Status: | assigned → new |
I'll take this one over. Initial value setting is very complicated. There's already a way of setting the initial value if the data is inlined into the HTML page (same way that you set the value for a plain HTML <select> element). But for other data providers it gets more complicated, especially for incrementalDataProvider.
The thing is that maybe you only have the value (the hidden value), like "CA", not the (displayed) label, like "California". So in the same way that we want to support
mySelectWidget.setValue("CA");
We want to support
<div dojoType=Select value="CA">
to set the initial value. See also bug #1504.
comment:10 Changed 14 years ago by
Owner: | changed from bill to Douglas Hays |
---|
comment:11 Changed 14 years ago by
Attached is my 'fix' for this, it really doesn't solve the issue, but does provide a work around in a way, by allowing you to set a value, or defaultValue. No protocol change needed for this patch..
Changed 14 years ago by
Attachment: | ComboBoxValuePatch.diff added |
---|
Patch file to add value (and defaultValue).
Changed 14 years ago by
Attachment: | ComboBoxValuePatch.2.diff added |
---|
[ccla] Patch file to add value (and defaultValue). total workaround
comment:12 Changed 14 years ago by
Autocompleter now supports the format Bill mentioned. You just set the value attribute in the HTML to the hidden value you want to load with.
Patch for ComboBox?