0

While updating data of a dojo tree using a REST Store I have to change the name of the item. caching is avoiding this change for items already used in the tree. How to disable caching. Here is a part of the code:

var prod= {
store: null,
model: null,
tree: null,

init: function() {
    this.store = new dojox.data.JsonRestStore({
        target: 'jtf-products-REST.php',
        labelAttribute: "name"
    });

    this.model = new dijit.tree.ForestStoreModel({
        store: this.store,
        deferItemLoadingUntilExpand: true,
        rootId: "products",
        rootLabel: "Products",
        query: {},          
        childrenAttrs: ['children']
    });
}};
//...
dojo.addOnLoad(function() { 
prod.init();
prod.tree = new dijit.Tree({
        model: prod.model,
        dndController: dijit.tree.dndSource,
        checkAcceptance:never,
        persist: false
    }, 'products_tree');
prod.tree.startup();
/...
function filterProducts() {
if (keyword = prompt("input")) {
    dijit.byId('products_tree').destroy(true);
    dojo.xhrPost({
        url: 'jtf-products.php',
        content: {
            key: keyword,
            type:'products'
        },
        //preventCache: true,
        load: function(response) {          
            dojo.byId('numberofproducts').innerHTML=response+" products";
            tree=prod.tree
            tree._itemNodesMap = {};

            tree.rootNode.state = "UNCHECKED";
            tree.model.root.children = null;
            if (tree.rootNode) {
                tree.rootNode.destroyRecursive();
            }

            tree._load();
            //...

Thank you.

Paul Ghobril
  • 143
  • 1
  • 1
  • 7
  • I am not sure. As far as I can remember you would set queryOptions:{cache:false} in the request (xhrPost). Please also note that dojo2 is out https://dojo.io https://dojo.io/blog/ – sebilasse May 08 '18 at 08:06
  • it is {preventCache: true} for xhrPost but this is not the problem. The problem is in the REST store which requests from the server. in the dojox/data/JsonRestStore document we can find "JsonRestStore caches objects that have been retrieved from the server locally in memory. " but there is no indication on how to disable it. – Paul Ghobril May 08 '18 at 09:40

1 Answers1

1

Try this:

this.store = new dojox.data.JsonRestStore({
   target: 'jtf-products-REST.php?_dc=' + new Date().getTime(),
RobC
  • 22,977
  • 20
  • 73
  • 80