Having trouble using the Adding Collection Data Search Functionality
Modified as follows but it does not populate any data into the results table
What am I doing wrong?
import wixData from "wix-data"; export function RegionFinder_click(event) { // Runs a query on the "School Districts collection wixData.query("School Districts") // Query the collection for any items whose "Name" field contains // the value the user entered in the input element .contains("schoolDistrict", $w("#searchBox").value) .find() // Run the query .then(res => { // Set the table data to be the results of the query $w("#resultsTable").rows = res.items; }); $w.onReady(function () { $w("#resultsTable").columns = [ { "id": "schoolDistrict", "dataPath": "schoolDistrict", "label": "School District", "type": "string", }, { "id": "region", "dataPath": "region", "label": "Region", "type": "number", }, { "id": "regionalDirector", "dataPath": "regionalDirector", "label": "Regional Director", "type": "string", }]; }); }
this code didn't; work
What am I doing wrong?
What you are doing wrong is --> You do not use a good formated CODE-STRUCTURE.
If you would do it, you would see all the errors inside your code emmidiately.
import wixData from "wix-data"; $w.onReady(()=>{ $w('#myButtonIDhere').onClick(()=>{ setupTable(); RegionFinder(); }); }); function setupTable() { $w("#resultsTable").columns = [ { "id": "schoolDistrict", "dataPath": "schoolDistrict", "label": "School District", "type": "string", }, { "id": "region", "dataPath": "region", "label": "Region", "type": "number", }, { "id": "regionalDirector", "dataPath": "regionalDirector", "label": "Regional Director", "type": "string", } ]; } function RegionFinder() { wixData.query("School Districts") .contains("schoolDistrict", $w("#searchBox").value) .find() .then(res => { console.log(res) $w("#resultsTable").rows = res.items; }); }