question about search function in a simple wixcode

Hi everyone ! I was trying to set up a simple wix code that could perform easy function such as type a word and i have a table that shows that info in the database.

I uses
// For full API documentation, including code examples, visit http://wix.to/94BuAAs
import wixData from ‘wix-data’;

$w.onReady(function () {
//TODO: write your page related code here…

});

export function searchButton_onclick(event) {
wixData.query(‘recommendation’).contains(‘newField’, $w(‘#input1’).value)
.find()
.then(res =>{$w(‘#table1’).rows= res.item;
});

}
and created a input field, a button and a table … but i cant really make that works…
the table change a bit after i hit the button but then it didnt show the data … it just react …

and i receive an error message : Wix code SDK Warning: The rows parameter that is passed to the rows method cannot be set to null or undefined.

any idea? thanks in advance!

any idea ??? T^T…

Hey Lis,

Welcome to the Wix Code forums.

Seems like you need items and not item .

Not this:
.then(res =>{$w(’ #table1 ').rows= res.item;
but this:
.then(res =>{$w(’ #table1 ').rows= res.items;

Let me know if that helps,

Yisrael

thanks Yisrael !! it helps ! the error message is gone… but the problem still here which is the table is not showing the search result… the table do change but then it changes to nothing … the first one is before i do anything… the second one is when i do hit the button for search … … thanks in advance !! Yisrael !

is it possible that i didnt link these 3 items correctly ??? because it doesnt seem connected , :frowning:

Hi Lis,

From what it looks like to me, you are searching in the recommendation field for a entry that has the lower-case (small) letter a . However, the table that you are displaying has all upper-case letters. Try searching for the upper-case letter A and you will probably get some results.

You could also do this:

wixData.query('recommendation').contains('newField', $w('#input1').value.toUpperCase())

This converts the entire search string to upper case for the filter.

Good luck,

Yisrael

Thanks for all your input Yisrael ! i find out why… it is because the connection between the table and the database XD… thanks !