Evening all.
I followed the guide below on adding collection data search functionality and everything works.
https://support.wix.com/en/article/corvid-tutorial-adding-collection-data-search-functionality
However, partial search terms are showing more data than they should.
As an example, I am searching a collection of customer contract pricing. Different customers have different contract pricing for the same product.
Imagine I had 2 rows in this collection with the column headers of:
Article code
Description
Code
Price
The article code and description in each of the two entries are the same with only the code and price changing.
Row 1 has code = “Code1” with a price of $2.00.
Row 2 has code = “Code2” with a price of $3.25.
Presently, the user can just enter “Cod” into the search box and this returns ALL results.
How do I stop the results from showing all entries in my collection when a partial code is entered and instead show a message on the screen such as “Code not recognised”?
import wixData from "wix-data";
//https://support.wix.com/en/article/corvid-tutorial-adding-collection-data-search-functionality
export function button1_click(event) {
// Runs a query on the "ProcureASSISTv1" collection
wixData.query("ProcureASSISTv1")
// Query the collection for any items whose "code" field contains
// the value the user entered in the input element
.contains("code", $w("#CodeInput").value)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
$w("#table1").rows = res.items;
});
}
$w.onReady(function () {
$w("#table1").columns = [{
"id": "image",
"dataPath": "image",
"label": "Image",
"type": "image",
}, {
"id": "description",
"dataPath": "description",
"label": "Description",
"type": "string",
}, {
"id": "colour",
"dataPath": "colour",
"label": "Colour",
"type": "string",
}, {
"id": "articleCode",
"dataPath": "articleCode",
"label": "Article Code",
"type": "string",
}, {
"id": "price",
"dataPath": "price",
"label": "Price",
"type": "string",
}];
});