Hello Wix geniuses,
I’m in need of your help.
I’ve built a site with a dataset (Tenant_Blacklist) with a function that allows users to search the dataset for the full name of a tenant in the dataset. That works fine (or at least it did until I tried this next bit).
I’ve tried to add a “no results found” message when the name searched doesn’t match any results in the dataset.
First I tried to add it as a text box that would only display if total count = 0. Couldn’t get that to work so I scrapped it and tried to display a default result (a line within the dataset that reads “no results found”) within the table if the results of the search =0.
It still won’t display the “no results found” and now it won’t display the results when there are results to display.
If anyone could help me it would be very much appreciated.
I’ll paste the page code below:
import wixData from “wix-data”;
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
//TODO: write your page related code here…
export function searchbutton_click(event) {
//Add your code for this event here:
// Runs a query on the “tenant” collection
wixData.query(“Tenant_Blacklist”)
// Query the collection for any items whose “Name” field contains
// the value the user entered in the input element
.contains(“tenantFullName”, $w(“#input7”).value)
.find() // Run the query
.then
(res1 => {
if (res1.items.length ===0) {
wixData.query(“Tenant_Blacklist”)
.eq(‘title’, “No Reviews Found”)
.find(res2 => {
// Set the table data to be the results of the query
$w(“#table1”).rows = res2.items;
});
}})
}
$w.onReady( function () {
$w(“#table1”).columns = [
{
“id”: “col1”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “Country”,
“label”: “Country”, // The column header
“width”: 150, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col2”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “tenantFullName”,
“label”: “Tenant Full Name”, // The column header
“width”: 150, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col3”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “DOB”,
“label”: “Date of Birth”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col4”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “scoreOutOf10”,
“label”: “Score Out Of 10”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col5”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “rentalAddress”,
“label”: “Rented Address”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col6”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “landlordPropertyManagerName”,
“label”: “Property Manager’s Name”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col7”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “landlordPropertyManagerPhoneNumber”,
“label”: “Property Manager Phone”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col8”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “reasonsForReviewScore”,
“label”: “Reviewer Notes”, // The column header
“width”: 100, // Column width
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “col9”,
“dataPath”: “photos”,
“label”: “photos”,
“visible”: true ,
“type”: “image”,
“linkPath”: “link-field-or-property”
},
// more column objects here if necessary
// …
// …
]});
Thanks in advance,
Leigh