Opened 13 years ago
Closed 13 years ago
#9322 closed enhancement (fixed)
Document how to update ItemFileReadStore
Reported by: | burnsmicro | Owned by: | Jared Jurkiewicz |
---|---|---|---|
Priority: | high | Milestone: | 1.4 |
Component: | Documentation | Version: | 1.3.0 |
Keywords: | update data store, refresh data store | Cc: | |
Blocked By: | Blocking: |
Description
The documentation in http://docs.dojocampus.org/dojo/data/ItemFileReadStore is either wrong or incomplete when it touches on updating a data store by "A new call to fetch will invoke the URL load or reparse the data object into a new list of items."
There is also a lot of noise and confusion about updating a data store, making this information very costly.
dataStore.close() and .fetch() will not refresh the dataStore created from a jsonData object ..unless dataStore._jsonData is first refeshed:
dataStore.close(); dataStore._jsonData = dataObject; // dataStore.fetch();
Also, dataStore.fetch() has no effect and may not be necessary when the data store is fed from a jsonData object.
The test code follows:
<html> <head> <title>DataStoreTest</title> <style type="text/css"> @import "http://o.aolcdn.com/dojo/1.3/dijit/themes/tundra/tundra.css"; </style> <script type="text/javascript" src="http://o.aolcdn.com/dojo/1.3/dojo/dojo.xd.js" djConfig="parseOnLoad:true, isDebug: true"> </script> <script type="text/javascript"> dojo.require("dijit.form.FilteringSelect"); dojo.require("dojo.data.ItemFileReadStore"); var dataObject = { identifier:"name", items:[{name:"Name-1"},{name:"Name-2"},{name:"Name-3"}] }; var count = 3; var selector; var dataStore; dojo.addOnLoad(function(){ dataStore = new dojo.data.ItemFileReadStore({data:dataObject, clearOnClose:true}); selector = new dijit.form.FilteringSelect({ id: "SelectBox", value: dataObject.items[0].name, store: dataStore, searchAttr: "name", name: "dojo", }, dojo.byId("SelectField")); }); function updateStore(){ dataObject.items.forEach(function(item){ count++; item.name = "Name-" + count.toString(); console.log(item.name); }); console.log(dataStore); dataStore.close(); dataStore._jsonData = dataObject; // dataStore.fetch(); // dataStore updates without this call console.log(dataStore); selector.store = dataStore; } </script> <body class="tundra"> <input id="SelectField"> <button onClick="updateStore()">Update</button> </body> </html>}}}
Attachments (3)
Change History (12)
Changed 13 years ago by
Attachment: | dataStoreTest.html added |
---|
comment:1 Changed 13 years ago by
Owner: | set to Jared Jurkiewicz |
---|
comment:3 Changed 13 years ago by
Milestone: | tbd → 1.4 |
---|
comment:4 Changed 13 years ago by
Summary: | Document how to update a data store → Document how to update ItemFileReadStore |
---|
Changed 13 years ago by
Attachment: | dataReset.patch added |
---|
comment:5 Changed 13 years ago by
comment:6 Changed 13 years ago by
comment:7 Changed 13 years ago by
comment:8 Changed 13 years ago by
comment:9 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Okay, I've updated IFS to make this simpler to do and updated the documentation on: http://docs.dojocampus.org/dojo/data/ItemFileReadStore to reflect this. The data example currently fails, but that is because I need the dojo version on campus updated before it will work. Closing this ticket as fixed.
Dat Store Test Code