[open-ils-commits] r9246 - in branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb: public/oils/media/js/openils/acq public/oils/media/js/util templates/oils/default/acq/financial

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Apr 7 11:36:09 EDT 2008


Author: erickson
Date: 2008-04-07 10:59:04 -0400 (Mon, 07 Apr 2008)
New Revision: 9246

Modified:
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js
   branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html
Log:
added a delay flag on the grid builder to allow for offsetting the setModel call until after data has been loaded into the store.  this allows a ref to the grid to be returned before data has been fetched.  added example onrowclick for the grid to test

Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js	2008-04-07 14:57:20 UTC (rev 9245)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js	2008-04-07 14:59:04 UTC (rev 9246)
@@ -8,20 +8,21 @@
     /* add instance methods here if necessary */
 });
 
+//openils.acq.FundingSource.loadGrid = function(domId, columns, gridBuiltHandler) {
 openils.acq.FundingSource.loadGrid = function(domId, columns) {
     /** Fetches the list of funding_sources and builds a grid from them */
 
+    var gridRefs = util.Dojo.buildSimpleGrid(domId, columns, [], 'id', true);
     var ses = new OpenSRF.ClientSession('open-ils.acq');
     var req = ses.request('open-ils.acq.funding_source.org.retrieve', 
         oilsAuthtoken, null, {flesh_summary:1}); /* XXX make this a streaming call */
 
     req.oncomplete = function(r) {
         srcs = r.recv().content();
-        var items = [];
 
         for(var f in srcs) {
             var src = srcs[f];
-            items.push({
+            gridRefs.store.newItem({
                 id:src.id(),
                 name:src.name(), 
                 owner: findOrgUnit(src.owner()).name(),
@@ -30,9 +31,12 @@
             });
         }
 
-        util.Dojo.buildSimpleGrid(domId, columns, items);
+        /* set the model after loading all of the data */
+        gridRefs.grid.setModel(gridRefs.model);
     };
     req.send();
+    //return gridRefs;
+    return gridRefs.grid;
 };
 }
 

Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js	2008-04-07 14:57:20 UTC (rev 9245)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js	2008-04-07 14:59:04 UTC (rev 9246)
@@ -11,12 +11,15 @@
 });
 
 
-util.Dojo.buildSimpleGrid = function(domId, columns, dataList, identifier) {
+util.Dojo.buildSimpleGrid = function(domId, columns, dataList, identifier, delayed) {
     /** Builds a dojo grid based on the provided data.  
      * @param domId The ID of the DOM node where the grid lives.
      * @param structure List of column header objects.
      * @param dataList List of objects (hashes) to be inserted into the grid.
-     * @paramd identifier The identifier field for objects in the grid.  Defaults to 'id'
+     * @param identifier The identifier field for objects in the grid.  Defaults to 'id'
+     * @param delayed If true, method returns before the model is linked to the grid. 
+     *      The purpose of this is to allow the client to fill the grid with data
+     *      before rendering to get past dojo grid display bugs
      */
     identifier = (identifier) ? identifier : 'id';
     domNode = dojo.byId(domId);
@@ -31,7 +34,11 @@
 
     var store = new dojo.data.ItemFileWriteStore({data:{identifier:identifier,items:dataList}});
     var model = new dojox.grid.data.DojoData(null, store, {rowsPerPage: 20, clientSort: true});
-    var grid = new dojox.Grid({structure: layout, model: model}, domId);
+    var grid = new dojox.Grid({structure: layout}, domId);
+
+    if(delayed)
+        return {grid:grid, store:store, model:model};
+
     grid.setModel(model);
     grid.setStructure(layout);
     grid.startup();

Modified: branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html
===================================================================
--- branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html	2008-04-07 14:57:20 UTC (rev 9245)
+++ branches/acq-experiment/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html	2008-04-07 14:59:04 UTC (rev 9246)
@@ -12,12 +12,13 @@
 </div>
 
 <div id='oils-acq-funding-source-grid'> </div>
+
 <script>
     dojo.require('openils.acq.FundingSource');
 
     /* define the layout columns */
     var cols = [
-        {name: '${_("ID")}', field: 'id'},
+        {name: '${_("ID")}', field: 'id', 'class':'id-column'},
         {name: '${_("Name")}', field: "name"}, 
         {name: '${_("Owner")}', field: "owner"}, 
         {name: '${_("Currency Type")}', field: "currency_type"},
@@ -25,7 +26,15 @@
     ];
 
     /* build the funding-source grid on page load */
-    dojo.addOnLoad(function(){
-        openils.acq.FundingSource.loadGrid('oils-acq-funding-source-grid', cols)});
+    dojo.addOnLoad(
+        function(){
+            var fsGrid = openils.acq.FundingSource.loadGrid('oils-acq-funding-source-grid', cols);
+            fsGrid.onRowClick = function(evt) {
+                /** XXX Need to make this more user friendly / obvious ... */
+                id = fsGrid.model.getDatum(evt.rowIndex, 0);
+                location.href = '${c.oils.acq.prefix.value}/funding_source/view/' + id;
+            };
+        }
+    );
 </script>
 </%def>



More information about the open-ils-commits mailing list