Note that there are some explanatory texts on larger screens.

plurals
  1. POdojo dijit.form.select : getting data out of the dataStore?
    primarykey
    data
    text
    <p>I am using dojo and want to populate a dijit.form.select widget from a dataStore (this works). Whenever I make a selection in the select-widget, other fields from my dataStore should be read and then be displayed in the textBoxes on the page.</p> <p>Unfortunately I dont know how to read the other fields from my data store. Here is my code:</p> <p><a href="http://jsbin.com/xxx" rel="nofollow">http://jsbin.com/xxx</a></p> <p>The important stuff happens if you scroll all the way down.</p> <p>Here is the javascript Object which is then read into the dataStore:</p> <p></p> <pre><code> 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"} ]}; &lt;/script&gt; </code></pre> <p>For ex when I select "name":"Messaging", "subject_main":"789", "subject_1":"sub1", "subject_2":"sub2"</p> <p>Messaging should be displayed in my dijit.</p> <p>EDIT: Lucian helped me a lot! Here is my final solution for the problem:</p> <blockquote> <p> </p> <pre><code>&lt;title&gt;Hello Dijit!&lt;/title&gt; &lt;!-- load Dojo --&gt; &lt;link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/dojo/1.8.1/dijit/themes/claro/claro.css"&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/dojo/1.8.1/dojo/dojo.js" </code></pre> <p>data-dojo-config="isDebug: true, async: true, parseOnLoad: true"> </p> <p> </p> <p>Beladeauftrag Adresse<br> <br> Navigation> <br></p> <pre><code>&lt;label for="load"&gt;Laden am&lt;/label&gt;&lt;br&gt; &lt;input type="text" value="" data-dojo-type="dijit/form/TextBox" data-dojo-props="trim:true, propercase:true" id="load" /&gt;&lt;br&gt; &lt;label for="from"&gt;von&lt;/label&gt;&lt;br&gt; &lt;input type="text" value="" data-dojo-type="dijit/form/TextBox" data-dojo-props="trim:true, propercase:true" id="from" /&gt;&lt;br&gt; &lt;label for="till"&gt;bis&lt;/label&gt;&lt;br&gt; &lt;input type="text" value="" data-dojo-type="dijit/form/TextBox" data-dojo-props="trim:true, propercase:true" id="till" /&gt;&lt;br&gt; &lt;script&gt; // load requirements for declarative widgets in page content require(["dijit/form/Button", "dojo/parser", "dijit/form/TextBox", "dojo/domReady!", "dojo/data/ItemFileReadStore"]); &lt;/script&gt; &lt;br&gt; &lt;br&gt; &lt;h2&gt;WF auswählen&lt;/h2&gt; &lt;div id="stateSelect"&gt;&lt;/div&gt; &lt;script&gt; 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", </code></pre> <p>"subject_1":"sub1", "subject_2":"sub2"} ]};</p> <pre><code> 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(); }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload