From 6ba407056722a6ee1e4f97454e0e02a3aa21439e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 10 Apr 2016 15:05:22 +1200 Subject: Implement group filtering function --- web/app/view/Devices.js | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js index ef79e643b..3dd81eb05 100644 --- a/web/app/view/Devices.js +++ b/web/app/view/Devices.js @@ -68,12 +68,39 @@ Ext.define('Traccar.view.Devices', { queryMode: 'local', displayField: 'name', valueField: 'id', - flex: 1/* TODO, + flex: 1, listeners: { change: function () { - this.up('grid').store.filter('groupId', this.getValue()); + if (Ext.isNumber(this.getValue())) { + this.up('grid').store.filter({ + id: 'groupFilter', + filterFn: function(item) { + var groupId, group, groupStore, filter = true; + groupId = item.get('groupId'); + groupStore = Ext.getStore('Groups'); + + while (groupId) { + group = groupStore.getById(groupId); + if (group) { + if (group.get('id') === this.getValue()) { + filter = false; + break; + } + groupId = group.get('groupId'); + } else { + groupId = 0; + } + } + + return !filter; + }, + scope: this + }); + } else { + this.up('grid').store.removeFilter('groupFilter'); + } } - }*/ + } }, { xtype: 'tbtext', html: Strings.sharedSearch -- cgit v1.2.3