PDA

View Full Version : [CLOSED] Is there a grid filters extension to select rows with empty (null) field values?



bogc
May 19, 2015, 5:11 PM
Hello:

I have a case where the users have to enter missing values (they are sparse) and I was thinking of providing a grid panel filter to select just the rows that are missing the values (the users need to see other data in order to know which values to put in the empty cells).

I found this: https://www.sencha.com/forum/showthread.php?238896-Little-Filter-Addon-empty-values-filtering and I was wondering if you have something similar integrated in Ext.Net.

In my case the columns contain dates but I guess this extension can be used with any columns.

Thanks!

Daniil
May 19, 2015, 9:43 PM
Hello @bogc,

Sorry, as far as I can remember there is no such thing built in Ext.NET.

bogc
May 20, 2015, 11:16 PM
I ended up implementing my own.



Ext.define('Ext.ux.grid.filter.DateFilterEx', {
extend: 'Ext.ux.grid.filter.DateFilter',
alias: 'gridfilter.datex',
uses: ['Ext.ux.grid.filter.DateFilter', 'Ext.menu.Menu'],

emptyText: 'Empty values',

menuItems: ['before', 'after', '-', 'on', '-', 'empty'],

compareMap: {
before: 'lt',
after: 'gt',
on: 'eq',
empty: 'empty'
},

init: function (config)
{

this.callParent(arguments);

// Let's remove the date menu associated with empty

this.fields.empty.menu = null;
},

onCheckChange : function(item, checked)
{
var me = this;

if (item == this.fields.empty)
{
me.setActive(me.isActivatable());
me.fireEvent('update', me);
return;
}
this.callParent(arguments);
},

validateRecord: function (record)
{
var val = record.get(this.dataIndex);

// If we want to see empty values and this is not an empty value then
// don't include this row
if (this.fields.empty.checked && val != null)
return false;

// If the value is null and any of the other filters are on then don't include any record
// because it doesn't make sense to compare a null against an existing date. If none of the filters
// are on then include the row
if (val == null)
return !this.fields.on.checked && !this.fields.before.checked && !this.fields.after.checked;

return this.callParent(arguments);
}
});

Daniil
May 22, 2015, 10:43 AM
Thank you very much for sharing!