How to update dojo tree data dynamically

后端 未结 7 889
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 14:39

I would like to know how ot update the data of the dojo.dijit.tree component dynamically. At the moment I\'m creating the tree using dojo.data.ItemFileReadStore and dijit.tree.F

7条回答
  •  悲&欢浪女
    2021-02-04 15:10

    Updating your store will automatically update your tree!

    1. You need a FileWriteStore, which gives you the ability to modify your data.
    2. Use the store to fetch the items you want to update via query.
    3. Update each item returned.
    4. Then save the store and the tree will update.

      FileWriteStore.fetch({
          query: { color: "red" },
          onComplete: function(items){
              for (var i = 0; i < items.length; i++){
                  FileWriteStore.setValue(items[i], "color", "green");
              }
              FileWriteStore.save();              
          }
      });
      

提交回复
热议问题