Skip to content

Commit

Permalink
TreeList: Fix getSelectedRowsData method when calling navigateToRow i…
Browse files Browse the repository at this point in the history
…n the onNodesInitialized event (T858312) (#11904)
  • Loading branch information
Alyar666 committed Feb 6, 2020
1 parent 3221df0 commit bc0fee0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/ui/tree_list/ui.tree_list.data_source_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,9 @@ let DataSourceAdapterTreeList = DataSourceAdapter.inherit((function() {
if(options.collapseVisibleNodes || expandedRowKeys.length) {
this.option('expandedRowKeys', expandedRowKeys);
}
this._isReload = false;
this.executeAction('onNodesInitialized', { root: this._rootNode });
this._isNodesInitializing = false;
this._isReload = false;
}

data = this._createVisibleItemsByNodes(this._rootNode.children, options);
Expand Down
34 changes: 33 additions & 1 deletion testing/tests/DevExpress.ui.widgets.treeList/selection.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const setupModule = function() {
};

that.setupTreeList = function() {
setupTreeListModules(that, ['data', 'columns', 'rows', 'selection', 'editorFactory', 'columnHeaders', 'filterRow', 'sorting', 'search'], {
setupTreeListModules(that, ['data', 'columns', 'rows', 'selection', 'editorFactory', 'columnHeaders', 'filterRow', 'sorting', 'search', 'focus'], {
initViews: true
});
};
Expand Down Expand Up @@ -497,6 +497,38 @@ QUnit.test('selection for nested node should works', function(assert) {
assert.strictEqual(this.getVisibleRows()[1].isSelected, true, 'row 1 is selected');
});

// T858312
QUnit.test('The getSelectedRowsData method should work correctly when calling navigateToRow in the onNodesInitialized event', function(assert) {
// arrange
const $testElement = $('#treeList');
const clock = sinon.useFakeTimers();

this.options.loadingTimeout = 30;
this.options.autoNavigateToFocusedRow = true;
this.options.onNodesInitialized = (e) => {
this.navigateToRow(2);
};

this.setupTreeList();
clock.tick(60);
this.rowsView.render($testElement);

// assert
assert.ok(this.getNodeByKey(1), 'node with key "1" exists');
assert.ok(this.getNodeByKey(2), 'node with key "2" exists');

// act
this.selectRows(2);

// assert
assert.deepEqual(this.getSelectedRowKeys(), [2], 'getSelectedRowKeys');
assert.deepEqual(this.option('selectedRowKeys'), [2], 'selectedRowKeys');
assert.deepEqual(this.getSelectedRowsData(), [{ id: 2, parentId: 1, field1: 'test2', field2: 2, field3: new Date(2002, 1, 2) }], 'getSelectedRowsData');

clock.restore();
});


QUnit.module('Recursive selection', {
beforeEach: function() {
setupModule.call(this);
Expand Down

0 comments on commit bc0fee0

Please sign in to comment.