Created
June 23, 2009 23:50
-
-
Save slackorama/134919 to your computer and use it in GitHub Desktop.
check to see if item exists in store and insert it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processData(item, request){ | |
var value = myStore.getValue(item, 'group'); | |
var exist = myStore.getValue(item, value); | |
var child = myStore.getValue(item, "name"); | |
console.debug(exist); | |
if (undefined == exist){ | |
console.debug(exist + " Create " + value + " " + child); | |
myStore.newItem({name: value, children:[{_reference: [child]}]}); | |
myStore.save; | |
} | |
} | |
var data = { identifier: 'name', label: 'name', items: [{ name:"Egypt", type:"country", group:"Africa" }]}; | |
dojo.require('dojo.data.ItemFileWriteStore'); | |
var myStore = new dojo.data.ItemFileWriteStore( { data: data }); | |
myStore.fetch( { onItem: processData}); | |
myStore.fetch( { onItem: function(item) { console.log( myStore.getValue( item, "name") ) } }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment