Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to delete items from a Tree
    primarykey
    data
    text
    <p>I've attempted to use this example and add basic CRUD to a tree.</p> <p><a href="http://dev.sencha.com/deploy/ext-4.0.0/examples/tree/treegrid.html" rel="nofollow noreferrer">http://dev.sencha.com/deploy/ext-4.0.0/examples/tree/treegrid.html</a></p> <p>For now, I just want to delete an item from the tree. I've added button and have this under click:</p> <pre><code>click : function() {; var record = tree.getSelectionModel().getSelection()[0]; store.destroy(record); store.sync(); } </code></pre> <p>I have verified the record and store exist. The store is of type TreeStore as in the example. If I check the request being sent, it's just <code>[]</code>. All I have in my proxy at the moment is this:</p> <pre><code>var store = Ext.create('Ext.data.TreeStore', { storeId : 'treeStore', model : 'Task', proxy : { type : 'ajax', // the store will get the content from the .json file url : '../resources/data/treegrid.json' }, folderSort : true }); </code></pre> <p>Clicking delete does not remove the currently selected item. Do I need to set up a proper destroy URL in the proxy, and why is it not sending any details about what needs to be deleted in the request header? There were no other examples of doing CRUD from a tree that I could find.</p> <p><img src="https://i.stack.imgur.com/stecU.png" alt="enter image description here"></p> <hr> <p><strong>EDIT:</strong></p> <p>Note that the reason for the confusion of using <code>store.destroy(record)</code> was that <a href="http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store" rel="nofollow noreferrer">Ext.data.Store</a> has a method <code>remove(record)</code> but <a href="http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.TreeStore" rel="nofollow noreferrer">Ext.data.TreeStore</a> does not. Also, a shorthand approach to destroying is <code>record.destroy()</code> rather than <code>record.remove(true)</code>. </p> <p>Note however that I received errors doing <code>record.destroy()</code> or <code>record.remove(true)</code>. Presumably the store needs to retain the nodes to send across as JSON, so use <code>record.remove()</code> instead.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload