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

Cascading issues #32

Open
HtangImpact opened this issue Aug 19, 2019 · 0 comments
Open

Cascading issues #32

HtangImpact opened this issue Aug 19, 2019 · 0 comments

Comments

@HtangImpact
Copy link

Not sure if this is because we are on 8.0, but we have a few issues with the Dropdown cascading.

I think I solved some of them, but I'm pretty new to Mendix and have little JavaScript experience. Not sure if my changes will have bad side effects yet.

First, we were getting a parsing error with the constraint. The upperFilter wasn't spit correctly and the newLowerOptionFilter needed a "/". Wish I saw #29 earlier. Could have saved me 2 hours but my fix is the same.

Then we noticed it was not cascading to multiple listeners. I fixed this by changing the find() to a filter() with a forEach().

The last thing, which I haven't found a fix for, is multi-select will not cascade down all selections. I think the problem is that each filter in that case needs an OR put between. Not sure how this can be accomplished. For our app, I changed it to be single-select and it's not a critical need but would be nice to have. Any help here would be appreciated

Thank you,
Horace Tang

Here is my modified function:
_cascadeToListeningWidgets: function () {
// refresh the listening dropdown
//var listenerWidget = this._searchWidgets[this.targetGridClass].find(function (w) {
// return w.listenPath && w.listenKey === this.cascadeKey
//}.bind(this));

var listenerWidgets = this._searchWidgets[this.targetGridClass].filter(function (w) {
	return w.listenPath && w.listenKey === this.cascadeKey
}.bind(this));
listenerWidgets.forEach(function(listenerWidget) {
	// if there's a listening widget
	if (listenerWidget) {
		/**
		 * upper filter
		 * lower option filter
		 * lower filter
		 * the upper filter affects the lower option filter
		 * if the filter on the listenerWidget dropdown needs to change, clear it
		 * if the filter on the listenerWidget doesn't need to change, do nothing
		 */
		//var upperFilter = this._getSearchConstraint().split(listenerWidget.listenPath).slice(-1)[0]; // last item in array
		var upperFilter = this._getSearchConstraint().split("/").slice(-1)[0];
		if (upperFilter) {
			var lowerOptionFilter = listenerWidget.searchWidget._datasource.getConstraints();
			//var newLowerOptionFilter = "[(" + listenerWidget.listenPath + upperFilter;
			var newLowerOptionFilter = "[(" + listenerWidget.listenPath + "/" + upperFilter;	

			if (lowerOptionFilter != newLowerOptionFilter) {
				// set new constraint
				listenerWidget.searchWidget._datasource.setConstraints(newLowerOptionFilter);
				// reload
				listenerWidget.searchWidget._datasource.reload();
				// reinit
				listenerWidget.searchWidget.reinit();
				listenerWidget._clear();
			}
		} else {
			listenerWidget.searchWidget._datasource.setConstraints();
			// reload
			listenerWidget.searchWidget._datasource.reload();
			// reinit
			listenerWidget.searchWidget.reinit();
			listenerWidget._clear();
		}
	}
}, this);

}

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