私は dojo を使用しており、dataStore から dijit.form.select ウィジェットを設定したいと考えています (これは動作します)。select-widget で選択を行うたびに、dataStore の他のフィールドを読み取って、ページの textBoxes に表示する必要があります。
残念ながら、データ ストアから他のフィールドを読み取る方法がわかりません。これが私のコードです:
一番下までスクロールすると、重要なことが起こります。
以下は、dataStore に読み込まれる JavaScript オブジェクトです。
var jsonData = {"identifier":"name",
"label": "subject_main",
"items": [
{"name":"departure", "subject_main":"123", "subject_1":"sub1", "subject_2":"sub2"},
{"name":"direct", "subject_main":"456", "subject_1":"sub1", "subject_2":"sub2"},
{"name":"Messaging", "subject_main":"789", "subject_1":"sub1", "subject_2":"sub2"},
{"name":"exchange", "subject_main":"1011", "subject_1":"sub1", "subject_2":"sub2"},
{"name":"Zilo", "subject_main":"1213", "subject_1":"sub1", "subject_2":"sub2"},
{"name":"Stub_implementation", "subject_main":"1415", "subject_1":"sub1", "subject_2":"sub2"},
{"name":"Standard_implementation", "subject_main":"1617", "subject_1":"sub1", "subject_2":"sub2"}
]};
</script>
たとえば、「name」:「Messaging」、「subject_main」:「789」、「subject_1」:「sub1」、「subject_2」:「sub2」を選択した場合
メッセージは私の dijit に表示されるはずです。
編集:ルシアンは私を大いに助けてくれました!問題に対する私の最終的な解決策は次のとおりです。
<title>Hello Dijit!</title> <!-- load Dojo --> <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/dojo/1.8.1/dijit/themes/claro/claro.css"> <script src="//ajax.googleapis.com/ajax/libs/dojo/1.8.1/dojo/dojo.js"
data-dojo-config="isDebug: true, async: true, parseOnLoad: true">
Beladeauftrag アドレス
ナビゲーション><label for="load">Laden am</label><br> <input type="text" value="" data-dojo-type="dijit/form/TextBox" data-dojo-props="trim:true, propercase:true" id="load" /><br> <label for="from">von</label><br> <input type="text" value="" data-dojo-type="dijit/form/TextBox" data-dojo-props="trim:true, propercase:true" id="from" /><br> <label for="till">bis</label><br> <input type="text" value="" data-dojo-type="dijit/form/TextBox" data-dojo-props="trim:true, propercase:true" id="till" /><br> <script> // load requirements for declarative widgets in page content require(["dijit/form/Button", "dojo/parser", "dijit/form/TextBox", "dojo/domReady!", "dojo/data/ItemFileReadStore"]); </script> <br> <br> <h2>WF auswählen</h2> <div id="stateSelect"></div> <script> require(["dijit/form/Select", "dojo/store/Memory", "dojo/json", "dijit/registry" , "dojo/ready"], function(Select, Memory, json, registry, ready) { ready(function(){ var jsonData = {"identifier":"name", "label": "subject_main", "items": [ {"name":"Auftrag 1", "subject_main":"123", "subject_1":"sub1", "subject_2":"sub2"}, {"name":"Auftrag 2", "subject_main":"456",
"subject_1":"sub1", "subject_2":"sub2"} ]};
var store1 = new dojo.data.ItemFileReadStore({ data: jsonData }); // code useless - nut dijit.form.select fanishes without it (??) // create Select widget, populating its options from the store var select = new Select({ name: "WorflowSelect", store: store1, style: "width: 200px;", labelAttr: "name", maxHeight: -1, // tells _HasDropDown to fit menu within viewport myAttr1: "this.get(name)", myAttr2: "subject_2", onChange: function(value){ // get references to widgets adressW=dijit.byId("adress"); loadW=dijit.byId("load"); fromW=dijit.byId("from"); tillW=dijit.byId("till"); adressW.attr("value", "subject_main from js-object"); loadW.attr("value", "subject_1 from js-object"); fromW.attr("value", "subject_2 from js-object"); tillW.attr("value", store1._getItemByIdentity("Auftrag 1").subject_main); } }, "stateSelect"); select.startup(); }); }); </script> </body> </html>