문제

i am using dropdown widget in dojo (dijit), i want to set the selected option the top menu

i tried this code:

dijit.byId('projectId').addOption({ label: item.projname , value: item.projid, selected:true  });

here the selected: true

is not working

Thanks

도움이 되었습니까?

해결책

The asker's code is not correct as the selected property applies for the construction of the object. As PaulR suggested, the asker should use dijit.byId('projectId').set("value",item.projid); when the select widget has already been created.

Aside: I would suggest using the AMD module "dijit/registry" rather than the root dijit object.

다른 팁

According to the documentation, "selected: true" is the correct way to specify the selected item. See https://dojotoolkit.org/reference-guide/1.9/dijit/form/Select.html.

I noticed the same issue in the past, and noticed that this only works correctly when an option has a value. So, can you check if "item.projid" contains a value?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top