Skip to content

Commit 297f768

Browse files
authored
UI.Gantt: fix task sorting when the sort column is hidden. (T1283506) (#29537)
1 parent 961705b commit 297f768

File tree

4 files changed

+53
-10
lines changed

4 files changed

+53
-10
lines changed

packages/devextreme/js/__internal/grids/grid_core/columns_controller/m_columns_controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ export class ColumnsController extends modules.Controller {
314314
}
315315

316316
public publicMethods() {
317-
return ['addColumn', 'deleteColumn', 'columnOption', 'columnCount', 'clearSorting', 'clearGrouping', 'getVisibleColumns', 'getVisibleColumnIndex'];
317+
return ['addColumn', 'deleteColumn', 'columnOption', 'columnCount', 'clearSorting', 'clearGrouping', 'getVisibleColumns', 'getVisibleColumnIndex', 'getColumns'];
318318
}
319319

320320
public applyDataSource(dataSource, forceApplying?, isApplyingUserState?) {

packages/devextreme/js/ui/gantt/ui.gantt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class Gantt extends Widget {
397397

398398
_sortAndFilter() {
399399
const treeList = this._treeList;
400-
const columns = treeList.getVisibleColumns();
400+
const columns = treeList.getColumns();
401401

402402
const sortedColumns = columns.filter(c => c.sortIndex > -1);
403403
const sortedState = sortedColumns.map(c => ({ sortIndex: c.sortIndex, sortOrder: c.sortOrder }));

packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/virtualColumns.tests.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ const setupModule = function() {
3636
}, options));
3737
};
3838

39-
this.getColumns = function(parameterNames) {
40-
return this.columnsController.getColumns();
41-
};
42-
4339
this.getFixedColumns = function(parameterNames) {
4440
return this.columnsController.getFixedColumns();
4541
};
@@ -537,10 +533,6 @@ const setupRenderingModule = function() {
537533
}, options));
538534
};
539535

540-
this.getColumns = function(parameterNames) {
541-
return this.columnsController.getColumns();
542-
};
543-
544536
this.clock = sinon.useFakeTimers();
545537
};
546538

packages/devextreme/testing/tests/DevExpress.ui.widgets/ganttParts/sorting.tests.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,4 +522,55 @@ QUnit.module('Sorting', moduleConfig, () => {
522522
assert.equal(this.instance._treeList.getVisibleRows().length, 3);
523523
});
524524

525+
test('check sorting by invisible column (T1283506)', function(assert) {
526+
const start = new Date('2019-02-21');
527+
const end = new Date('2019-02-26');
528+
const tasks = [
529+
{ 'id': 1, 'parentId': 0, 'title': 'Software Development', 'start': new Date('2019-02-21'), 'end': new Date('2019-02-22'), 'progress': 0 },
530+
{ 'id': 2, 'parentId': 1, 'title': 'Scope', 'start': new Date('2019-02-20'), 'end': new Date('2019-02-22'), 'progress': 0 },
531+
{ 'id': 3, 'parentId': 1, 'title': 'Determine project scope', 'start': start, 'end': end, 'progress': 50 }
532+
];
533+
const options = {
534+
tasks: { dataSource: tasks },
535+
validation: { autoUpdateParentTasks: false },
536+
sorting: { mode: 'single' },
537+
columns:
538+
[
539+
{
540+
dataField: 'id',
541+
},
542+
{
543+
dataField: 'title'
544+
},
545+
{
546+
dataField: 'start',
547+
visible: false,
548+
sortOrder: 'desc'
549+
}
550+
]
551+
};
552+
553+
this.createInstance(options);
554+
this.clock.tick(10);
555+
556+
const treeListIdText1 = $(this.instance._treeList.getCellElement(0, 0)).text();
557+
const treeListTitleText1 = $(this.instance._treeList.getCellElement(0, 1)).text();
558+
const treeListIdText2 = $(this.instance._treeList.getCellElement(1, 0)).text();
559+
const treeListTitleText2 = $(this.instance._treeList.getCellElement(1, 1)).text();
560+
const treeListIdText3 = $(this.instance._treeList.getCellElement(2, 0)).text();
561+
const treeListTitleText3 = $(this.instance._treeList.getCellElement(2, 1)).text();
562+
563+
const taskText1 = this.$element.find(Consts.TASK_SELECTOR)[0].textContent;
564+
const taskText2 = this.$element.find(Consts.TASK_SELECTOR)[1].textContent;
565+
const taskText3 = this.$element.find(Consts.TASK_SELECTOR)[2].textContent;
566+
567+
assert.equal(treeListIdText1, '1');
568+
assert.equal(treeListIdText2, '3');
569+
assert.equal(treeListIdText3, '2');
570+
571+
assert.equal(treeListTitleText1, taskText1);
572+
assert.equal(treeListTitleText2, taskText2);
573+
assert.equal(treeListTitleText3, taskText3);
574+
});
575+
525576
});

0 commit comments

Comments
 (0)