Note that there are some explanatory texts on larger screens.

plurals
  1. POdijit.Tree search and refresh
    text
    copied!<p>I can't seem to figure out how to search in a dijit.Tree, using a ItemFileWriteStore and a TreeStoreModel. Everything is declarative, I am using Dojo 1.7.1, here is what I have so far :</p> <pre><code>&lt;input type="text" dojoType="dijit.form.TextBox" name="search_fruit" id="search_fruit" onclick="search_fruit();"&gt; &lt;!-- store --&gt; &lt;div data-dojo-id="fruitsStore" data-dojo-type="dojo.data.ItemFileWriteStore" clearOnClose="true" urlPreventCache="true" data-dojo-props='url:"fruits_store.php"'&gt;&lt;/div&gt; &lt;!-- model --&gt; &lt;div data-dojo-id="fruitsModel" data-dojo-type="dijit.tree.TreeStoreModel" data-dojo-props="store:fruitsStore, query:{}"&gt;&lt;/div&gt; &lt;!-- tree --&gt; &lt;div id="fruitsTree" data-dojo-type="dijit.Tree" data-dojo-props='"class":"container", model:fruitsModel, dndController:"dijit.tree.dndSource", betweenThreshold:5, persist:true'&gt; &lt;/div&gt; </code></pre> <p>The json returned by fruits_store.php is like this :</p> <pre><code>{"identifier":"id", "label":"name", "items":[{"id":"OYAHQIBVbeORMfBNZXFGOHPdaRMNUdWEDRPASHSVDBSKALKIcBZQ","name":"Fruits","children":[{"id":"bSKSVDdRMRfEFNccfTZbWHSACWbLJZMTNHDVVcYGcTBDcIdKIfYQ","name":"Banana"},{"id":"JYDeLNIGPDBRMcfSTMeERZZEUUIOMNEYYcNCaCQbCMIWOMQdMEZA","name":"Citrus","children":[{"id":"KdDUfEDaKOQMFNJaYbSbAcAPFBBdLALFMIPTFaYSeCaDOFaEPbJQ","name":"Orange"},{"id":"SDWbXWbTWKNJDIfdAdJbbbRWcLZFJHdEWASYDCeFOZYdcZUXJEUQ","name":"Lemon"}]},{"id":"fUdQTEZaIeBIWCHMeBZbPdEWWIQBFbVDbNFfJXNILYeBLbWUFYeQ","name":"Common ","children":[{"id":"MBeIUKReBHbFWPDFACFGWPePcNANPVdQLBBXYaTPRXXcTYRTJLDQ","name":"Apple"}]}]}]} </code></pre> <p>Using a grid instead of a tree, my search_fruit() function would look like this :</p> <pre><code>function search_fruit() { var grid = dijit.byId('grid_fruits'); grid.query.search_txt = dijit.byId('search_fruit').get('value'); grid.selection.clear(); grid.store.close(); grid._refresh(); } </code></pre> <p>How to achieve the same using the tree ? Thanks !</p>
 

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