Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TreeList: Add node property for a detail adaptive row #11871

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions js/ui/grid_core/ui.grid_core.adaptivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ module.exports = {
rowType: ADAPTIVE_ROW_TYPE,
key: item.key,
data: item.data,
node: item.node,
modifiedValues: item.modifiedValues,
isNewRow: item.isNewRow,
values: item.values
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
QUnit.testStart(function() {
const markup =
'<div class="dx-treelist dx-widget">\
<div id="container"></div>\
</div>';
$('#qunit-fixture').html(markup);
});

import 'common.css!';
import 'generic_light.css!';
import 'ui/tree_list/ui.tree_list';

import $ from 'jquery';
import treeListMocks from '../../helpers/treeListMocks.js';
import renderer from 'core/renderer';

function setupTreeList(that, $treeListContainer) {
that.$element = function() {
return $treeListContainer ? $treeListContainer : renderer('.dx-treelist');
};

if(that.columns !== null) {
that.columns = that.columns || [
{ dataField: 'firstName', index: 0, allowEditing: true, allowExporting: true },
{ dataField: 'lastName', index: 1, allowEditing: true, allowExporting: true }
];
}

that.items = that.items || [
{ id: 1, parentId: 0, firstName: 'TestTestTestTestTestTestTestTest1', lastName: 'Psy' },
{ id: 2, parentId: 1, firstName: 'Super', lastName: 'Star' }
];

that.options = $.extend({}, {
keyExpr: 'id',
parentIdExpr: 'parentId',
rootValue: 0,
columns: that.columns,
dataSource: {
asyncLoadEnabled: false,
store: that.items
},
expandedRowKeys: [],
columnHidingEnabled: true
}, that.options);

that.setupOptions = {
initViews: true
};

treeListMocks.setupTreeListModules(that, ['data', 'columns', 'rows', 'columnHeaders', 'masterDetail', 'editing', 'adaptivity', 'columnsResizingReordering', 'keyboardNavigation', 'gridView'], that.setupOptions);
}

QUnit.module('API', {
beforeEach: function() {
this.clock = sinon.useFakeTimers();
},
afterEach: function() {
this.clock.restore();
}
});

QUnit.test('The detail adaptive row should have the node property', function(assert) {
// arrange
$('.dx-treelist').width(200);

setupTreeList(this);
this.rowsView.render($('#container'));
this.resizingController.updateDimensions();
this.clock.tick();

// act
this.adaptiveColumnsController.expandAdaptiveDetailRow(1);
this.clock.tick();

// assert
const rows = this.getVisibleRows();
assert.ok($('.dx-adaptive-detail-row').length, 'render field items');
assert.strictEqual(rows[1].rowType, 'detailAdaptive', 'detail adaptive row');
assert.deepEqual(rows[1].node, rows[0].node, 'detail adaptive row has the node property');
});