Thanks for the great comments and code examples on this thread folks, though I would appreciate a little help as I experiment with some of the examples provided. I am pretty new to the coding side of things so excuse my efforts!
I have a Settlements dynamic page that displays a table of jobs from a different data collection.
I’m simply trying to filter a list of jobs by the name of the settlement.
The jobs dataset has a field called Location that is a text string that is manually populated with settlement names.
So I want to filter the jobs displayed in the table by filtering the content by Location = settlement_name
The Dynamic Dataset is named: Demo_settlements Item
The field that the Settlement name is contained in is called: settlement_name
The Dataset I want to filter is named: Demo_jobs_contracts dataset
Here’s the code I have used:
import wixData from “wix-data”;
let filter = wixData.filter;
$w.onReady(function () {
//TODO: write your page related code here...
$w("#dynamicDataset").onReady(() => {
const tagName = $w("#dynamicDataset").getCurrentItem().settlement_name;
$w("#Demo_jobs_contracts dataset").setFilter(filter().eq("Location", tagName));
});
//....... last brackets here, my code above
});
But I’m unable to get it to work and receive the following errors:
On the Page Code panel I get a warning message on the first line:
ESLint failed to validate this file because an error occured: unknown character at position 6
However the first line of my Page Code is:
import wixData from “wix-data”;
When I save and preview the code I get the following output:
Loading the code for the Demo_settlements (Settlement_name) page. To debug this code, open zqg9j.js in Developer Tools.
Wix code SDK Warning: The text parameter that is passed to the text method cannot be set to null or undefined.
TypeError: $w(…).setFilter is not a function
Could anyone help steer me with where or what I am doing wrong? Appreciate any help!