PDA

View Full Version : [OPEN] Broken column menu for tree panel with filters plugin



nikolay.bobrovskiy
6 Oct 2014, 5:08 AM
Please, try to open column's menu in the fiddle https://fiddle.sencha.com/#fiddle/bc2
You will get exception.

Gary Schlosberg
6 Oct 2014, 3:59 PM
Thanks for the report! I have opened a bug in our bug tracker.

lnegi
8 Oct 2014, 7:56 AM
here is my fix for this :

Ext.application({
name: 'Fiddle',


launch: function() {


Ext.define('Ext.plugin.TreeFilter', {
extend: 'Ext.grid.filters.Filters',
alias: 'plugin.treefilter',
onMenuBeforeShow: function (menu) {
var me = this,
menuItem, filter, ownerGrid, ownerGridId;


if (me.showMenu) {




if (!me.menuItems) {
me.menuItems = {};
}


// only this line is changed , this.grid is added
ownerGrid = menu.up('grid') || this.grid ;
ownerGridId = ownerGrid.id;


menuItem = me.menuItems[ownerGridId];


if (!menuItem || menuItem.isDestroyed) {
menuItem = me.createMenuItem(menu, ownerGridId);
}


me.activeFilterMenuItem = menuItem;


filter = me.getMenuFilter(ownerGrid.headerCt);
if (filter) {
filter.showMenu(menuItem);
}


menuItem.setVisible(!!filter);
me.sep.setVisible(!!filter);
}
}
});










Ext.widget('treepanel', {
renderTo: Ext.getBody(),
store: {
type: 'tree',
root: {
children: [{
text: 'test'
}]
}
},
rootVisible: false,
plugins: [{
ptype: 'treefilter'
}],
columns: [{
name: 'text',
dataIndex: 'text'
}]
});
}
});

PlasmaTek
2 Dec 2014, 3:40 AM
Any more on this? I still get the error "headerCt.getMenu(...).activeHeader is undefined" even after adding the above fix.

nikolay.bobrovskiy
2 Dec 2014, 3:49 AM
Still not fixed for 5.1.0.50. I think waiting for more than half of an year (like for EXTJS-14984) and we can get fix :)

PlasmaTek
4 Dec 2014, 1:00 AM
My fix so far


Ext.define('Ext.plugin.TreeFilter', {
extend: 'Ext.grid.filters.Filters',
alias: 'plugin.treefilters',
onMenuBeforeShow: function (menu) {
this.currentlyActiveHeader = menu.ownerCmp;
var me = this,
menuItem, filter, ownerGrid, ownerGridId;
if (me.showMenu) {
if (!me.menuItems) {
me.menuItems = {};
}
// this.grid is added
ownerGrid = menu.up('grid') || this.grid;
ownerGridId = ownerGrid.id;
menuItem = me.menuItems[ownerGridId];
if (!menuItem || menuItem.isDestroyed) {
menuItem = me.createMenuItem(menu, ownerGridId);
}

me.activeFilterMenuItem = menuItem;
filter = me.getMenuFilter(ownerGrid.headerCt);

if (filter) {
filter.showMenu(menuItem);
}

menuItem.setVisible(!!filter);
me.sep.setVisible(!!filter);
}
},
getMenuFilter: function (headerCt) {
headerCt.getMenu().activeHeader = this.currentlyActiveHeader;
return headerCt.getMenu().activeHeader.filter;
},
onCheckChange: function (item, value) {
item.activeFilter.setActive(value);
if (!value) { this.clearFilters(false); }
}

});

cpaul
16 Jan 2015, 12:09 PM
Using ExtJS 5.1, Tree Panel with columns config.

Error: "Uncaught TypeError: Cannot read property 'id' of undefined"

solution:
As with the other solutions here, override the onMenuBeforeShow() method of 'Ext.grid.filters.Filters'

You just need to change one line:

ownerGrid = menu.up('grid') || menu.up('treepanel');

odibo
20 May 2015, 6:55 AM
As for ExtJs 5.1.1 the error message is gone. I removed the override from code. The override has been very handy with 5.1.0.




Ext.override(Ext.ClassManager.get('Ext.grid.filters.Filters'), {

/**
* Column filter problem in trees
* http://www.sencha.com/forum/showthread.php?292910-Broken-column-menu-for-tree-panel-with-filters-plugin
*/
onMenuBeforeShow: function (menu) {
var me = this,
menuItem, filter, ownerGrid, ownerGridId;


if (me.showMenu) {
// In the case of a locked grid, we need to cache the 'Filters' menuItem for each grid since
// there's only one Filters instance. Both grids/menus can't share the same menuItem!
if (!me.menuItems) {
me.menuItems = {};
}


// Don't get the owner panel if in a locking grid since we need to get the unique menuItems key.
//ownerGrid = me.grid; <-- old
ownerGrid = menu.up('grid') || menu.up('treepanel'); // <-- new
ownerGridId = ownerGrid.id;


menuItem = me.menuItems[ownerGridId];


if (!menuItem || menuItem.isDestroyed) {
menuItem = me.createMenuItem(menu, ownerGridId);
}


// Save a ref to the root "Filters" menu item, column filters make use of it.
me.activeFilterMenuItem = menuItem;


filter = me.getMenuFilter(ownerGrid.headerCt);
if (filter) {
filter.showMenu(menuItem);
}


menuItem.setVisible(!!filter);
me.sep.setVisible(!!filter);
}
}
});

mankz
9 Jul 2015, 11:42 PM
BUMP for getting grid-filters in a tree - even with a few overrides it only returns root level matches. Needs some extra work I think.

Animal
20 Sep 2015, 6:50 AM
This is fixed under ticket https://sencha.jira.com/browse/EXTJS-18474

mankz
20 Sep 2015, 6:59 AM
That's good news. It'll be in 6.0.2?

mankz
21 Nov 2015, 1:27 AM
Bump, done in 6.0.2?

mankz
13 Dec 2015, 7:16 AM
Not fixed in 6.0.1. Only works for top level nodes. Try filtering for qqq:

https://fiddle.sencha.com/#fiddle/12ge