javascript - Is there a way to only show parent nodes in a extjs tree -


i want show parent nodes of tree in extjs. in datastore there leaf nodes well.

the output should -

 folder 1    folder 1.1 folder 2 folder 3 

create filter object gets parent nodes , add store config:

e.g. filter parent nodes only:

var nodefilter = new ext.util.filter({     property: 'leaf',     value   : false }); 

putting on treestore config:

var yourtreestore = ext.create('ext.data.treestore', {     // other configs ...     filters: [nodefilter] }); 

edit:

incutonez right, submitted according api properties did not notice missing functions. easy enough override though apply filtering treestore though. working me in 4.1b2:

ext.override(ext.data.treestore, {      hasfilter: false,      filter: function(filters, value) {          if (ext.isstring(filters)) {             filters = {                 property: filters,                 value: value             };         }          var me = this,             decoded = me.decodefilters(filters),             = 0,             length = decoded.length;          (; < length; i++) {             me.filters.replace(decoded[i]);         }          ext.array.each(me.filters.items, function(filter) {             ext.object.each(me.tree.nodehash, function(key, node) {                 if (filter.filterfn) {                     if (!filter.filterfn(node)) node.remove();                 } else {                     if (node.data[filter.property] != filter.value) node.remove();                 }             });         });         me.hasfilter = true;      },      clearfilter: function() {         var me = this;         me.filters.clear();         me.hasfilter = false;         me.load();     },      isfiltered: function() {         return this.hasfilter;     }  }); 

with overrride in code, create "leaf only" filter function or property/value pair per ext.util.filter api:

// leaf filter property/value pair var nodefilter = new ext.util.filter({     property: 'leaf',     value   : false });  // leaf filter function var nodefilter = ext.create('ext.util.filter', {   filterfn: function(item) {     return !item.data.leaf;   } }); 

you call filter function whenever take out leaf nodes:

mytreestore.filter(nodefilter); 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -

delphi - How to convert bitmaps to video? -