From f19ca64ccbbe23ce3926ccdf140cdafb14375602 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 7 Apr 2008 14:59:04 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@9246 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../public/oils/media/js/openils/acq/FundingSource.js | 10 +++++++--- .../web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js | 13 ++++++++++--- .../oils/default/acq/financial/list_funding_sources.html | 15 ++++++++++++--- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js index 094f507c88..6b22e287fc 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/openils/acq/FundingSource.js @@ -8,20 +8,21 @@ dojo.declare('openils.acq.FundingSource', null, { /* 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 @@ openils.acq.FundingSource.loadGrid = function(domId, columns) { }); } - 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; }; } diff --git a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js index 90afcbacb8..e49cafceae 100644 --- a/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js +++ b/Open-ILS/web/oilsweb/oilsweb/public/oils/media/js/util/Dojo.js @@ -11,12 +11,15 @@ dojo.declare('util.Dojo', null, { }); -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 @@ util.Dojo.buildSimpleGrid = function(domId, columns, dataList, identifier) { 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(); diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html index da76fac9af..b41e174b24 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_funding_sources.html @@ -12,12 +12,13 @@
+ -- 2.11.0