Thanks for your response,
I worked a few things out since, but I can’t quite get what I want.
At the moment I have a coded Table that appears showing the results of a search based on 3 fields (Forename, Surname and BookingRef). There will only ever be one result for this search (or no matches), so I want the results to be displayed in the table, but then the user should be able to click on the record and it take them to a Dynamic page via the BookingRef.
I am trying to add a link behind the LinkPath, but cannot find the right format for this, and don’t know if I need a new function for this to work?
Also, if there are zero results from the search, I just want the table to not display and a message appear stating no results found.
Also, if you are also able to help, I am trying to combine the forename and surname fields for display in the table. The below does not seem to work.
Code below so far
import wixData from ‘wix-data’;
$w.onReady( function () {
$w(“#BookingResults”).columns = [
{
“id”: “BookRef”, // ID of the column for code purposes
// The field key in the collection whose data this column displays
“dataPath”: “bookingRef”,
“label”: “Booking Reference”, // The column header
“width”: 100, // Column width
“visible”: true , // Column visibility
“type”: “string”, // Data type for the column
// Path for the column if it contains a link
“linkPath”: “link-field-or-property”
},
{
“id”: “Name”,
“dataPath”: “customerFirstName” + " " + “customerSurname”,
“label”: “Name”,
“width”: 100,
“visible”: true ,
“type”: “String”,
“linkPath”: “link-field-or-property”
} //,
// more column objects here if necessary
// …
// …
];
});
export function Search_click(event, $w) {
// Runs a query on the “Members” collection
wixData.query(‘Bookings’)
// Query the collection for any items whose “Name” field contains
// the value the user entered in the input element
.eq(‘customerFirstName’, $w(‘#Forename’).value)
.eq(‘customerSurname’, $w(‘#Surname’).value)
.eq(‘bookingRef’, $w(‘#InsertRefNo’).value)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
$w(‘#BookingResults’).rows = res.items;
});
}