[Dojo-interest] How to connect to datastore in declarative dijit

Bjørn Willy Arntzen Bjorn-Willy.Arntzen at klp.no
Wed Mar 24 02:37:15 EDT 2010


Thanks, of cource I knew that, I just copied some old code I had, and that didn't use datastore, but a ordinary array, but it worked...

My primary issue was to find a way to create code that was executed after the datastore was populated. Is this the best way to do it, with a decalarative datastore ?

Med vennlig hilsen/Best regards 

Bjørn-Willy Arntzen 
Seniorkonsulent IT/Arkitektur, 



Kommunal Landspensjonskasse gjensidig forsikringsselskap
Karl Johansgt. 41b, Pb 1733 Vika, NO-0121 Oslo 
Tlf: 22033685 / 97759007 
www.klp.no


-----Original Message-----
From: dojo-interest-bounces at mail.dojotoolkit.org [mailto:dojo-interest-bounces at mail.dojotoolkit.org] On Behalf Of Jared Jurkiewicz
Sent: 24. mars 2010 05:01
To: dojo-interest at mail.dojotoolkit.org
Subject: Re: [Dojo-interest] How to connect to datastore in declarative dijit

Incorrect.  The correct way:

    <div dojoType="dojo.data.ItemFileReadStore"
        jsId="fondStore" url="jaxrs/fond/total2" >

       <script type="dojo/method">
                        var ul = dojo.create("ul", null, "fondUrls", "first");
                        var request = fondStore.fetch({
                                        query: {key : "urls*"},
                                        onItem: function(item,request){
                                              var li =
dojo.create("li", {}, ul);
                                              dojo.create("a", { href:
fondStore.getValue(item, "href"), title: fondStore.getValue(item,
"label"), innerHTML: fondStore.getValue(item. "label")}, li);
                                        }
                        });
                </script>
    </div>

See docs:
http://docs.dojocampus.org/dojo/data/
http://docs.dojocampus.org/quickstart/data/usingdatastores/fetchmultiple

-- Jared


2010/3/23 Bjørn Willy Arntzen <Bjorn-Willy.Arntzen at klp.no>:
> I found it mayself : Is this the right way to do it ?
>
>
>    <div dojoType="dojo.data.ItemFileReadStore"
>        jsId="fondStore" url="jaxrs/fond/total2" >
>
>       <script type="dojo/method">
>                        var ul = dojo.create("ul", null, "fondUrls", "first");
>                        var request = fondStore.fetch({
>                                        query: {key : "urls*"},
>                                        onItem: function(item,request){
>                                              var li = dojo.create("li", {}, ul);
>                                              dojo.create("a", { href: item.href, title: item.label, innerHTML: item.label}, li);
>                                        }
>                        });
>                </script>
>    </div>
>
> Med vennlig hilsen/Best regards
>
> Bjørn-Willy Arntzen
> Seniorkonsulent IT/Arkitektur,
>
>
>
> Kommunal Landspensjonskasse gjensidig forsikringsselskap
> Karl Johansgt. 41b, Pb 1733 Vika, NO-0121 Oslo
> Tlf: 22033685 / 97759007
> www.klp.no
>
>
> -----Original Message-----
> From: dojo-interest-bounces at mail.dojotoolkit.org [mailto:dojo-interest-bounces at mail.dojotoolkit.org] On Behalf Of Bjørn Willy Arntzen
> Sent: 23. mars 2010 22:14
> To: dojo-interest at mail.dojotoolkit.org
> Subject: [Dojo-interest] How to connect to datastore in declarative dijit
>
> Hello all.
>
> I'm reading the fantastick book 'Mastering Dojo' and have created a declarative Grid. Incredible simle todo !!!
>
> Here's the code
>
>   <div dojoType="dojo.data.ItemFileReadStore" jsId="fondStore" url="jaxrs/fond/total">
>   </div>
>
>    <table id="grid" dojoType="dojox.grid.Grid" store="fondStore"
>         query="{ key: '*' }" clientSort="true">
>        <thead>
>           <tr>
>              <th field="ledetekst" width="15em">Fond</th>
>              <th field="anskaffelsesverdi">Anskaffelsesverdi</th>
>              <th field="markedsverdi">Markedsverdi</th>
>              <th field="avkastning">Avkastning</th>
>           </tr>
>        </thead>
>
>    </table>
>    <div id="fondUrls">hjg</div><br>
>    </body>
>
> I'm really wondering how to populate the "fondUrls" from the datastore.
>
> The datastore is loaded from a RESTService, and works like a charm, but there is also a list of urls in the response that is being loaded into the fondStore. So my problem is :
>
> How can I connect to the load: function when the datastore is finished ? I just want to polulate my urls.
>
> Med vennlig hilsen/Best regards
>
> Bjørn-Willy Arntzen
> Seniorkonsulent IT/Arkitektur,
>
>
>
> Kommunal Landspensjonskasse gjensidig forsikringsselskap
> Karl Johansgt. 41b, Pb 1733 Vika, NO-0121 Oslo
> Tlf: 22033685 / 97759007
> www.klp.no
>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://docs.dojocampus.org
> Dojo-interest at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://docs.dojocampus.org
> Dojo-interest at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
>
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
Dojo-interest at mail.dojotoolkit.org
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


More information about the Dojo-interest mailing list