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

Proper filtering of whole words #2

Open
AngelusDomini opened this issue Mar 4, 2022 · 1 comment
Open

Proper filtering of whole words #2

AngelusDomini opened this issue Mar 4, 2022 · 1 comment

Comments

@AngelusDomini
Copy link

Hi. I'm tryna get this filter array thingy to work properly:

let isFiction = ['non-fiction','fiction'];

When selecting non-fiction, the table shows all of my nonfiction book notes as desired, but selecting fiction shows both non-fiction and fiction books. How would I change the filter array to not include non-fiction when selecting fiction? I can easily do this with normal Dataview, but don’t know how on dataviewjs. Is this currently possible? Or is this somewhat related to one of the issues you mentioned on the README?

There is no way to exclude values. Might change the checkboxes to custom divs with states so you can chose wheter you want to turn it off, include or exclude from the filter.

@kuroshirouma
Copy link
Owner

kuroshirouma commented Mar 4, 2022

Right now there are 2 options to make this work:

  1. Write the frontmatter as fiction: Yes and fiction: No and use "Yes" and "No" as the values you search for (like i did for "concentration" in the Spells example)
  2. Change your frontmatter key values to arrays, so if you have something like type: fiction you would change it into type: [fiction] or
type:
  - fiction

After that change the if statement in isChecked function from

if (fltArr.length > 0) {
	match = fltArr.some(r => q[categories[i].fmName].includes(r));
	}

to

if (fltArr.length > 0) {
	match = fltArr.some(r => {
			if (q[categories[i].fmName].indexOf(r) != -1) { return true }
			});
	}

I haven't really had time to work on this unfortunatelly, but i hope this will help you for the time being.

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

2 participants