Query a database with user input and display matching records. Help!

This is my first attempt to interact with users and query a database. I have tried numerous examples and have not had luck with any of them. I imported the collection. It needs to be read only. All I want to do is ask the user to enter their lake address and search the db for a match. Then display the results of the matching entries in a table. After that, I would like have the user choose their address from the matches (but I’m not to that point yet).

Here is the code:
import wixData from ‘wix-data’ ;

function resetForm() {
const inputList = $w( ‘#searchBox’ );
inputList.forEach(element => {
element.value = ‘’ ;

export function searchButton_click(event) {
wixData.query( “HLAGIS” )
.contains( “lakeAddress” ,$w( ‘#searchBox’ ).value)
.then(res => {
$w( “#table1” ).rows = res.items;
$w( “#table1” ).expand();

$w.onReady( function () {
// id is for code purposes; datapath is the collection field name; label is the column title;
$w( “#table1” ).columns = [{ “id” : “Col1” , “dataPath” : “lakeAddress” , “label” : “Lake Address” , “type” : “string” },
{ “id” : “Col2” , “dataPath” : “parcelNumber” , “lable” : “Parcel #” , “type” : “string” },
{ “id” : “Col3” , “datapath” : “name” , “lable” : “Name” , “type” : “string” },
{ “id” : “Col4” , “datapath” : “mailAddress” , “lable” : “Mail Address” , “type” : “string” },
{ “id” : “Col5” , “datapath” : “city” , “lable” : “city” , “type” : “string” },
{ “id” : “Col6” , “datapath” : “state” , “lable” : “state” , “type” : “string” },
{ “id” : “Col7” , “datapath” : “zip” , “lable” : “zip” , “type” : “string” }

The dataset is Read-only. Here is what the interaction preview looks like:

What am I doing wrong? Thank you in advance!

What is inputList? You aren’t using it (except to clear it when you reset).

Not sure if you have the correct columns configuration. For one thing, you have label mispelled in all but the first column. Also, it’s dataPath , and not datapath.

You will need to review the Table API, especially the columns and rows properties to ensure that you have everything configured correctly.

Do you know that your query is returning any results? You should check your query.

Hi, Yisrael. Thanks for responding. I’m new to Java, so I have been trying a bunch of stuff and reading. I’m at the point where the input field is accepted and the query is performed with the correct items in the array. I’ve change things a bit. I moved the column definitions and corrected the punctuation (I was really frustrated when I did the first post and should have checked it. sorry).

Nothing is displaying on the table. I have tried connecting the table’s fields to the dataset, I have tried it without connecting to the dataset. Nothing is working. Everything is read only so all I want to do is display. at this point. The only property that I am using is “Hidden on Load”.

OK. Well, that is it. I just tried unchecking that and it works. I thought “Hidden on Load” meant hide the table when first displaying the page (ie wait until the input is entered and the db is queried, THEN display the table). OMG!

Well, I guess I learned a lot trying for how many hours to get this STUPID thing to display! Sometimes the tiniest little things can screw you up!

Thank you. Very much. The documentations recommendations were good. Thx.

1 Like