[Lada-commits] [PATCH] Added column filter to orte grid
Wald Commits
scm-commit at wald.intevation.org
Thu Feb 2 16:43:56 CET 2017
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1486050233 -3600
# Node ID 6075731bc4f1b5da1d69ba0d5a4e2eb9c3a8b9d3
# Parent 152fca74a83905a8a7d08ddb6cc11545a831966e
Added column filter to orte grid.
diff -r 152fca74a839 -r 6075731bc4f1 app.js
--- a/app.js Thu Feb 02 15:46:05 2017 +0100
+++ b/app.js Thu Feb 02 16:43:53 2017 +0100
@@ -11,7 +11,8 @@
paths: {
'Ext.i18n': 'resources/lib/ext/i18n/',
'Ext.ux.upload': 'resources/lib/ext/upload',
- 'Ext.ux.util': 'resources/lib/ext/util'
+ 'Ext.ux.util': 'resources/lib/ext/util',
+ 'Ext.ux.grid': 'resources/lib/ext/grid'
}
});
@@ -31,6 +32,7 @@
'Lada.override.i18n.DE',
'Lada.override.JSON',
'Lada.override.RowExpander',
+ 'Lada.override.StringFilter',
'Lada.view.plugin.GridRowExpander',
'Ext.i18n.Bundle',
'Ext.layout.container.Column',
diff -r 152fca74a839 -r 6075731bc4f1 app/override/StringFilter.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/override/StringFilter.js Thu Feb 02 16:43:53 2017 +0100
@@ -0,0 +1,33 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+
+Ext.define('Lada.override.StringFilter', {
+ override: 'Ext.ux.grid.filter.StringFilter',
+
+ validateRecord: function(record) {
+ if (this.dataIndex === 'gemId') {
+ var store = Ext.data.StoreManager.get('verwaltungseinheiten');
+ var item = store.getById(record.get('gemId'));
+ var comp = item.get('bezeichnung');
+ return comp.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;
+ }
+ else if (this.dataIndex === 'staatId') {
+ var store = Ext.data.StoreManager.get('staaten');
+ var item = store.getById(record.get('staatId'));
+ var comp = item.get('staatIso');
+ return comp.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;
+ }
+ else {
+ var val = record.get(this.dataIndex);
+ if(typeof val != 'string') {
+ return (this.getValue().length === 0);
+ }
+ return val.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;
+ }
+ }
+});
diff -r 152fca74a839 -r 6075731bc4f1 app/view/grid/Orte.js
--- a/app/view/grid/Orte.js Thu Feb 02 15:46:05 2017 +0100
+++ b/app/view/grid/Orte.js Thu Feb 02 16:43:53 2017 +0100
@@ -13,6 +13,9 @@
extend: 'Ext.grid.Panel',
alias: 'widget.ortstammdatengrid',
+ requires: [
+ 'Ext.ux.grid.FiltersFeature'
+ ],
// minHeight and deferEmptyText are needed to be able to show the
// emptyText message.
minHeight: 110,
@@ -27,6 +30,7 @@
readOnly: true,
allowDeselect: true,
editableGrid: true,
+ features: [],
initComponent: function() {
var i18n = Lada.getApplication().bundle;
@@ -42,6 +46,21 @@
this.plugins = [this.rowEditing];
}
+ filters = {
+ ftype: 'filters',
+ // encode and local configuration options defined previously for easier reuse
+ encode: false, // json encode the filter query
+ local: true, // defaults to false (remote filtering)
+
+ // Filters are most naturally placed in the column definition, but can also be
+ // added here.
+ filters: [{
+ type: 'boolean',
+ dataIndex: 'visible'
+ }]
+ };
+ this.features = [filters];
+
this.columns = [{
xtype: 'actioncolumn',
text: 'RW',
@@ -83,6 +102,9 @@
maxLength: 10,
allowBlank: false
},
+ filter: {
+ type: 'string'
+ },
dataIndex: 'ortId'
}, {
header: i18n.getMsg('orte.nutsCode'),
@@ -90,6 +112,9 @@
xtype: 'textfield',
maxLength: 10
},
+ filter: {
+ type: 'string'
+ },
dataIndex: 'nutsCode'
}, {
header: i18n.getMsg('orte.anlageId'),
@@ -101,6 +126,9 @@
header: i18n.getMsg('orte.verwaltungseinheit'),
dataIndex: 'gemId',
width: 120,
+ filter: {
+ type: 'string'
+ },
renderer: function(value) {
if (!value) {
return '';
@@ -120,6 +148,9 @@
header: i18n.getMsg('orte.staatId'),
dataIndex: 'staatId',
width: 70,
+ filter: {
+ type: 'string'
+ },
renderer: function(value) {
if (value === undefined || value === '') {
return '';
@@ -137,6 +168,9 @@
}
}, {
header: i18n.getMsg('orte.kdaId'),
+ filter: {
+ type: 'numeric'
+ },
editor: {
xtype: 'numberfield',
allowBlank: false
@@ -144,12 +178,21 @@
dataIndex: 'kdaId'
}, {
header: i18n.getMsg('orte.ozId'),
+ filter: {
+ type: 'string'
+ },
dataIndex: 'ozId'
}, {
header: i18n.getMsg('orte.ortTyp'),
+ filter: {
+ type: 'numeric'
+ },
dataIndex: 'ortTyp'
}, {
header: i18n.getMsg('orte.mpArt'),
+ filter: {
+ type: 'string'
+ },
editor: {
xtype: 'textfield',
maxLength: 10
@@ -157,6 +200,9 @@
dataIndex: 'mpArt'
}, {
header: i18n.getMsg('orte.zone'),
+ filter: {
+ type: 'string'
+ },
editor: {
xtype: 'textfield',
maxLength: 1
@@ -164,6 +210,9 @@
dataIndex: 'zone'
}, {
header: i18n.getMsg('orte.sektor'),
+ filter: {
+ type: 'string'
+ },
editor: {
xtype: 'textfield',
maxLength: 2
@@ -171,6 +220,9 @@
dataIndex: 'sektor'
}, {
header: i18n.getMsg('orte.zustaendigkeit'),
+ filter: {
+ type: 'string'
+ },
editor: {
xtype: 'textfield',
maxLength: 10
@@ -178,6 +230,9 @@
dataIndex: 'zustaendigkeit'
}, {
header: i18n.getMsg('orte.berichtstext'),
+ filter: {
+ type: 'string'
+ },
editor: {
xtype: 'textfield',
maxLength: 70
@@ -185,6 +240,9 @@
dataIndex: 'berichtstext'
}, {
header: i18n.getMsg('orte.kurztext'),
+ filter: {
+ type: 'string'
+ },
editor: {
xtype: 'textfield',
maxLength: 15,
@@ -193,6 +251,9 @@
dataIndex: 'kurztext'
}, {
header: i18n.getMsg('orte.langtext'),
+ filter: {
+ type: 'string'
+ },
editor: {
xtype: 'textfield',
maxLength: 100,
@@ -201,18 +262,27 @@
dataIndex: 'langtext'
}, {
header: i18n.getMsg('orte.unscharf'),
+ filter: {
+ type: 'string'
+ },
editor: {
xtype: 'textfield'
},
dataIndex: 'unscharf'
}, {
header: i18n.getMsg('orte.hoeheLand'),
+ filter: {
+ type: 'numeric'
+ },
editor: {
xtype: 'numberfield'
},
dataIndex: 'hoeheLand'
}, {
header: i18n.getMsg('orte.koordXExtern'),
+ filter: {
+ type: 'string'
+ },
editor: {
xtype: 'textfield',
maxLength: 22,
@@ -221,6 +291,9 @@
dataIndex: 'koordXExtern'
}, {
header: i18n.getMsg('orte.koordYExtern'),
+ filter: {
+ type: 'string'
+ },
editor: {
xtype: 'textfield',
maxLength: 22,
@@ -229,18 +302,27 @@
dataIndex: 'koordYExtern'
}, {
header: i18n.getMsg('orte.longitude'),
+ filter: {
+ type: 'numeric'
+ },
editor: {
xtype: 'numberfield'
},
dataIndex: 'longitude'
}, {
header: i18n.getMsg('orte.latitude'),
+ filter: {
+ type: 'numeric'
+ },
editor: {
xtype: 'numberfield'
},
dataIndex: 'latitude'
}, {
header: i18n.getMsg('letzteAenderung'),
+ filter: {
+ type: 'date'
+ },
xtype: 'datecolumn',
format: 'd.m.Y H:i',
dataIndex: 'letzteAenderung'
diff -r 152fca74a839 -r 6075731bc4f1 app/view/window/Ortszuordnung.js
--- a/app/view/window/Ortszuordnung.js Thu Feb 02 15:46:05 2017 +0100
+++ b/app/view/window/Ortszuordnung.js Thu Feb 02 16:43:53 2017 +0100
@@ -130,7 +130,7 @@
layout: 'fit',
name: 'ortgrid',
hidden: true,
- maxHeight: 240,
+ height: 240,
items: [{
xtype: 'ortstammdatengrid'
}],
diff -r 152fca74a839 -r 6075731bc4f1 install-dependencies.sh
--- a/install-dependencies.sh Thu Feb 02 15:46:05 2017 +0100
+++ b/install-dependencies.sh Thu Feb 02 16:43:53 2017 +0100
@@ -39,4 +39,6 @@
unzip -n Ext-ux-Upload-1-1-1.zip
ln -sf extjs-upload-widget-1.1.1/lib/upload upload
+ln -sf ../../../extjs/examples/ux/grid grid
+
cd $CUR_DIR
More information about the Lada-commits
mailing list