Skip to content

Commit

Permalink
PivotGrid: Fix texts.emptyValue was not working (T852897) (#11671)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtoming830 authored Jan 24, 2020
1 parent c71c837 commit 1bb160f
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
8 changes: 8 additions & 0 deletions js/ui/pivot_grid/ui.pivot_grid.field_chooser_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ const FieldChooserBase = Widget.inherit(columnStateMixin).inherit(sortingMixin).
} else {
const d = new Deferred();
dataSource.getFieldValues(mainGroupField.index, that.option('headerFilter.showRelevantValues'), paginate ? options : undefined).done(function(data) {
const emptyValue = that.option('headerFilter.texts.emptyValue');

data.forEach((element) => {
if(!element.text) {
element.text = emptyValue;
}
});

if(paginate) {
d.resolve(data);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,80 @@ QUnit.test('headerFilter items if showRelevantValues is true', function(assert)
], 'getFieldValues calling args');
});

// T852897
QUnit.test('Custom texts.emptyValue in header filter', function(assert) {
const that = this;
let listItems;
let fieldElements;
const fields = [
{ caption: 'Field 1', area: 'column', index: 0, areaIndex: 0, allowSorting: true, allowFiltering: true }
];
const dataSourceOptions = {
columnFields: fields,
fieldValues: [
[{ value: 1, text: '1' }, { value: 2, text: '' }]
]
};

this.setup(dataSourceOptions, {
headerFilter: {
texts: {
emptyValue: 'Test'
}
}
});

$.each(fields, function(_, field) {
that.$container.append(that.fieldChooser.renderField(field));
});

fieldElements = that.$container.find('.dx-area-field');

// act
fieldElements.first().find('.dx-header-filter').trigger('dxclick');
this.clock.tick(500);

// assert
listItems = $('.dx-list').dxList('instance').option('items');

assert.equal(listItems.length, 2, 'header filter items');
assert.equal(listItems[1].text, 'Test');
});

// T852897
QUnit.test('Default texts.emptyValue in header filter', function(assert) {
const that = this;
let listItems;
let fieldElements;
const fields = [
{ caption: 'Field 1', area: 'column', index: 0, areaIndex: 0, allowSorting: true, allowFiltering: true }
];
const dataSourceOptions = {
columnFields: fields,
fieldValues: [
[{ value: 1, text: '' }, { value: 2, text: '2' }]
]
};

this.setup(dataSourceOptions);

$.each(fields, function(_, field) {
that.$container.append(that.fieldChooser.renderField(field));
});

fieldElements = that.$container.find('.dx-area-field');

// act
fieldElements.first().find('.dx-header-filter').trigger('dxclick');
this.clock.tick(500);

// assert
listItems = $('.dx-list').dxList('instance').option('items');

assert.equal(listItems.length, 2, 'header filter items');
assert.equal(listItems[0].text, '(Blanks)');
});

QUnit.module('applyChangesMode: onDemand', {
beforeEach: function() {
this.$container = $('#container');
Expand Down

0 comments on commit 1bb160f

Please sign in to comment.