Wednesday, October 16, 2013

one way to populate a list of object details in dojo/dojox

<ul class="displayList" data-dojo-type="dojox.mobile.RoundRectDataList"
      data-dojo-attach-point="summaryList"></ul>

 
 

Assuming the HTML above, we could use the code below:

define([
   "dojo/_base/lang",
   "dojo/data/ItemFileReadStore",
   "dojox/mobile/RoundRectDataList"
], function (
   lang,
   ItemFileReadStore
) {
   return {
      init: function() {
         app = this.app;
      },
      
      beforeActivate: function(current, data) {
         if(data && data.mdoElt !== undefined) {
            this.mdoElt = data.mdoElt;
            this.displayData();
         }
      },
      
      displayData: function() {
         var workRequest = this.mdoElt || {};
         var app = this.app;
         var items = [];
         items.push({
            label: "Foo",
            rightText: this.mdoElt.foo
         });
         items.push({
            label: "Bar",
            rightText: this.mdoElt.bar
         });
         items.push({
            label: "Baz",
            rightText: this.mdoElt.baz
         });
         items.push({
            label: "Qux",
            rightText: this.mdoElt.qux
         });
         var store = new ItemFileReadStore({ data: { items: items }});
         this.summaryList.setStore(store);
      }
   };
});

No comments:

Post a Comment