From dd6ed7a4f6002e7b32d2965a447735840ba6c7d1 Mon Sep 17 00:00:00 2001 From: Konstantin Volnyagin Date: Mon, 2 Sep 2019 16:41:55 +0300 Subject: [PATCH] DataGrid: Fix searched text highlighting for group rows in React (T808974) (#9517) --- js/ui/grid_core/ui.grid_core.search.js | 8 +++-- .../rowsView.tests.js | 36 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/js/ui/grid_core/ui.grid_core.search.js b/js/ui/grid_core/ui.grid_core.search.js index 6820fa0fa380..06c06699c4dc 100644 --- a/js/ui/grid_core/ui.grid_core.search.js +++ b/js/ui/grid_core/ui.grid_core.search.js @@ -285,8 +285,12 @@ module.exports = { if(!$parent.length) { $parent = $("
").append(cellElement); } else if(column) { - columnIndex = that._columnsController.getVisibleIndex(column.index); - $items = $parent.children("td").eq(columnIndex).find("*"); + if(column.groupIndex >= 0 && !column.showWhenGrouped) { + $items = cellElement; + } else { + columnIndex = that._columnsController.getVisibleIndex(column.index); + $items = $parent.children("td").eq(columnIndex).find("*"); + } } $items = $items && $items.length ? $items : $parent.find("*"); diff --git a/testing/tests/DevExpress.ui.widgets.dataGrid/rowsView.tests.js b/testing/tests/DevExpress.ui.widgets.dataGrid/rowsView.tests.js index 9f208147cc8d..c0e03305ca71 100644 --- a/testing/tests/DevExpress.ui.widgets.dataGrid/rowsView.tests.js +++ b/testing/tests/DevExpress.ui.widgets.dataGrid/rowsView.tests.js @@ -1059,6 +1059,42 @@ QUnit.test("Highlighting search text for boolean column with set to 'falseText' assert.strictEqual(getNormalizeMarkup($cells.eq(0)), "No", "highlight text in cell"); }); +QUnit.test("Highlighting search text for group row if templatesRenderAsynchronously is true (T808974)", function(assert) { + // arrange + var columns = [{ + allowCollapsing: true, + allowFiltering: true, + cssClass: "dx-command-expand", + groupIndex: 0, + command: "expand", + caption: "Group", + dataType: "string" + }, { + allowFiltering: true, + dataType: "string", + dataField: "name" + }], + rowsView = this.createRowsView([ + { data: { key: "TestGroup", items: null }, values: ["TestGroup"], rowType: "group", groupIndex: 0 } + ], null, columns), + $testElement = $("#container"), + $cells; + + this.options.searchPanel = { + highlightSearchText: true, + text: "Test" + }; + this.options.templatesRenderAsynchronously = true; + + // act + rowsView.render($testElement); + this.clock.tick(); + + // assert + $cells = $testElement.find(".dx-group-row").find("td"); + assert.strictEqual(getNormalizeMarkup($cells.eq(1)), "Group: TestGroup", "highlight text in cell"); +}); + QUnit.test('All rows are not isSelected by default', function(assert) { // arrange var rowsView = this.createRowsView(this.items),