Hi,
I am very new to dojo and I am stuck on this issue. When I try to add a new option, the error "addOption is not a function" arises. This is my code:
Widget.js:
function(
declare,
BaseWidget,
Button,
_TemplatedMixin,
_WidgetsInTemplateMixin,
FilteringSelect,
on,
keys,
Parser,
Memory,
array,
lang,
map,
FeatureSet,
Query,
QueryTask
) {
return declare([BaseWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
name: 'Cerca via',
baseClass: 'jimu-widget-CercaVia',
query: null,
queryTask: null,
postCreate: function() {
console.log("postCreate!");
var mapFrame = this;
this.inherited(arguments);
this.ComuniSelect.addOption({disabled:false,label:'label',selected:true,value:1});
},Widget.html:

Can someone point me in the right direction?
Bonus question: I would like to add to the FilteringSelect the option to search in the middle of the options. I read that this is possible setting queryExpr to "*$0*". How do I put it into my code?
Thanks,
Marco
Solved! Go to Solution.
Marco,
I don't normally add an item to my FilteringSelect, I normally clear it and add a new store. Here is what I believe will work:
var myStore = this.ComuniSelect.get('store');
myStore.put({disabled:false,label:'label',selected:true,value:1});
this.ComuniSelect.set('store', myStore);Bonus question:
this.ComuniSelect.set('queryExpr', '*${0}*');
I Just discovered that there is not the addOption function for FilteringSelect. So I suppose that I have to work with stores... Can someone show me how to do this?
Thanks,
Marco
Marco,
I don't normally add an item to my FilteringSelect, I normally clear it and add a new store. Here is what I believe will work:
var myStore = this.ComuniSelect.get('store');
myStore.put({disabled:false,label:'label',selected:true,value:1});
this.ComuniSelect.set('store', myStore);Bonus question:
this.ComuniSelect.set('queryExpr', '*${0}*');
Thanks, Robert!
The solution you proposed for the bonus question works like a charm.
For the main question I think that I will follow your method: I will clear the FilteringSelect and add a new store. I think it is the best way to accomplish what I want to do.