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

(ColumnSet +) CompoundColumns_findSortArrowParent(field) fails to find parent out of the 1st column set #1474

Open
claudeG opened this issue Jun 26, 2020 · 0 comments

Comments

@claudeG
Copy link

claudeG commented Jun 26, 2020

Hello !
We worked with Dgrid-0.3 plus an integration layer for several years and I am currently preparing the upgrade to the lastest Dgrid.

I have the case of an OnDemandGrid that results from declare([MyOnDemanGrid, ColumnHider, ColumnResizer, CompoundColumns, ColumnSet, Keyboard, Editor, DijitRegistry], {...})
where MyOnDemanGrid results from declare([OnDemandGrid, Selector, MouseOverEvents, ProgressDialog], {...}).

This grid instance holds 2 sets of columns. In boths sets, columns may be sortable or not.
When the header of a sortable column is clicked, the sort arrow must update.
In our case, the retrieval of the sort arrow node relies on CompoundColumns_findSortArrowParent(field) because the "this._sortNode" is null.

The issue I encounter :
When I click the header label from the second column set, such a node is not found. Debugging CompoundColumns_findSortArrowParent(field),

	_findSortArrowParent: function () {
		var parent = this.inherited(arguments),
			spacerRow = query('.dgrid-spacer-row', this.headerNode)[0],
			columnId,
			nodes;

		if (parent && spacerRow.contains(parent)) {
			columnId = parent.columnId;
			nodes = query('.dgrid-column-' + columnId, this.headerNode);
			return nodes[nodes.length - 1];
		}
	}

I noted that the node search is constrained by spacerRow.contains(parent) where spacerRow is the 1st '.dgrid-spacer-row' element. But our case fails because 'parent' belongs to the 2nd spacerRow. PROBLEM.

The way I solved this issue temporary:

lang.extend(CompoundColumns, {
	_findSortArrowParent: function(field) {
		// dgrid/CompoundColumns searches for 'parent' in the first '.dgrid-spacer-row' element only
		// while it exists as many '.dgrid-spacer-row' elements as compound column sets
		var parent = this.inherited("_findSortArrowParent", arguments); // Grid
		if (parent) {
			var allSpacerRows = query('.dgrid-spacer-row', this.headerNode);
			var someSpacerRowContainsParent = allSpacerRows.some(function(row) {
				return row.contains(parent);
			});
			if(someSpacerRowContainsParent) {
				var columnId = parent.columnId;
				var nodes = query('.dgrid-column-' + columnId, this.headerNode);
				return nodes[nodes.length - 1];						
			}
		}
	}
});

One more issue (I did not try to correct it) : The presence of a given data column should not be required to be unique in a grid. Sorting any column instance should be reflected on the sort icon of each of its "clones".

Thanks for your attention.

Claude

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant