Skip to content

Commit

Permalink
TreeList: Add node property for a detail adaptive row (#11871)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alyar666 committed Feb 5, 2020
1 parent dd442db commit c42e9d3
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
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 @@ -1027,6 +1027,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');
});

0 comments on commit c42e9d3

Please sign in to comment.