Opened 10 years ago

Closed 10 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)

dataStoreTest.html (1.5 KB) - added by burnsmicro 10 years ago.
Dat Store Test Code
dataReset.patch (3.2 KB) - added by Jared Jurkiewicz 10 years ago.
AndOr_dataReset.patch (8.3 KB) - added by Jared Jurkiewicz 10 years ago.
Similar patch for AndOr? stores

Download all attachments as: .zip

Change History (12)

Changed 10 years ago by burnsmicro

Attachment: dataStoreTest.html added

Dat Store Test Code

comment:1 Changed 10 years ago by bill

Owner: set to Jared Jurkiewicz

comment:2 Changed 10 years ago by Jared Jurkiewicz

Patch tested on FF3, IE7, Safari 3.2.3

comment:3 Changed 10 years ago by Jared Jurkiewicz

Milestone: tbd1.4

comment:4 Changed 10 years ago by Jared Jurkiewicz

Summary: Document how to update a data storeDocument how to update ItemFileReadStore

Changed 10 years ago by Jared Jurkiewicz

Attachment: dataReset.patch added

comment:5 Changed 10 years ago by Jared Jurkiewicz

(In [17602]) Patch to allow reset of data via the 'data' param. \!strict refs #9322

Changed 10 years ago by Jared Jurkiewicz

Attachment: AndOr_dataReset.patch added

Similar patch for AndOr? stores

comment:6 Changed 10 years ago by Jared Jurkiewicz

(In [17603]) Patch to allow reset of data via the 'data' param for AndOr? stores. \!strict refs #9322

comment:7 Changed 10 years ago by Jared Jurkiewicz

(In [17604]) Minor tweak to close to avoid blowup during load if close is called. \!strict refs #9322

comment:8 Changed 10 years ago by Jared Jurkiewicz

(In [17605]) Minor tweak to close to avoid blowup during load if close is called. \!strict refs #9322

comment:9 Changed 10 years ago by Jared Jurkiewicz

Resolution: fixed
Status: newclosed

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.

Note: See TracTickets for help on using tickets.