1

How can I make the store observable for the ItemFileWriteStore function below?Am I using the correct syntax below? It isn't working in my code, please suggest.

 store = new dojo.store.Observable(dojo.data.ItemFileWriteStore{
target:'store'
url: "my url"

}

I have written a small function in my dojo tree code as below to add new child folder under the parent folder of the tree structure created but it is not getting saved finally in the store. It is opening till the prompt "Folder name", after that when I add the folder name and click on ok, it is not saving in the folder tree structure. can someone suggest where it is going wrong?

Here is my code to create new folder which isnt working:

function myFunction(item){
item.name = prompt("Folder name");
var childItem = {
              name: "New Folder",
              id: Math.random(),
              parent: item.id
            };
 store.put(childItem, {overwrite: true
                  });

           store.put(item);
         } 
Dojo_user
  • 281
  • 4
  • 9
  • 28

1 Answers1

0

dojo.data.ItemFileWriteStore is old dojo data store which will be deprecated in the future. The recommended new dojo stores are in dojo.store module, like Memory store and JsonRest store.

dojo.store.Observable only works with new dojo.store . You can do:

  1. Either change your dojo.data.ItemFileWriteStore to dojo.store.Memory

  2. or wrap your dojo.data.ItemFileWriteStore with dojo.store.DataStore

Sean Zhao
  • 1,506
  • 12
  • 12
  • Hi Sean, I tried but it is not working for my case. Here in my case I have a ItemFileWriteStore wrapped as Observable, and an empty query() being observed by a function. When adding new objects (folder)put() with a new id the observing function is triggered. However,if I put() an object to update it in the store,the observer is not notified and nothing is being updated. Please find below my present code in fiddle link.I tried to use memory store as wellbut it is not working with observable and new folders are not getting added to the tree. http://jsfiddle.net/deb73268/EQeSh/1/ – Dojo_user Oct 08 '13 at 02:20