Data does not exist in repeater

This is code which came from the CodeQueen. This is the second page “results” of a multiple search. Shelter4 is my database and sName and sNumber are two fields within. The repeater is named shelterList. The repeater shows up with all records but does not filter out what was in the #searchBar. I get an error message of the line:
$w(‘#shelterList’).data = res.items; Where data has a red underline and the message is “‘data’ doesn’t exist on ‘shelterList’”.
Any thoughts what I might have missed?
Thanks,
Jeff

import {local} from ‘wix-storage’;
import wixData from ‘wix-data’;

$w.onReady( function () {
var sameWord = local.getItem(“searchWord”);
$w(“#searchBar”).value = sameWord;
$w(“#searchBar”).placeholder = sameWord;
$w(‘#dataset1’).onReady( function () {
search();
});
});

export function searchButton_click(event) {
search();
}

function search() {
wixData.query(‘Shelter4’)
.contains(‘sName’, $w(“#searchBar”).value)
.or(wixData.query(‘Shelter4’).eq(‘sNumber’, $w(“#searchBar”).value))
.find()
.then(res => {
$w(‘#shelterList’).data = res.items;

}); 

}

Check that your dataset id is actually ‘#dataset1’ in the properties panel or by hovering over the element itself as on Nayeli’s example her dataset is called ‘Name’, however for the code she has to use the id name which is ‘#nameDataset’.

Also, check that the ‘sName’ and ‘sNumber’ are the field keys of the fields in your dataset and not just the field name.
https://support.wix.com/en/article/about-your-database-collection-fields

Finally, with you using Nayeli (Code Queen) tutorial as shown here:
https://codequeen.wixsite.com/search-redirect/code

Then have you also watched her video which goes through the tutorial in detail, which should help you see where you need it:
https://www.youtube.com/watch?v=ZiKcx2nlrkw

Hi,
Thanks for the quick reply and the thorughness of your answers. However, I’ve checked the dataset name, the database name, the field keys and I’ve watched the video 4 times. I see hers works, but mine doesn’t. Any more clues?

@jeffhanner10

Is #shelterList a Repeater ? Your error message “‘data’ doesn’t exist on ‘shelterList’” seems to indicate that it is not a Repeater . Repeaters have a .data property which is used to set the contents of the Repeater.

If you continue to experience problems, please post the editor URL of your site. Only authorized Wix personnel can get access to your site in the editor. Please include the name of the page involved.

@yisrael-wix Yes, shelterList is the name of the repeater. It displays with all of the records but is not filtered as described in the video. The URL is https://jeffhanner10.wixsite.com/rcshelters. There are two pages in test which you can only access through the editor. The first is “test page search” and the second is “results”. the search starts in page 1 and ends up in results. As you will see this is for the Red Cross. I am a volunteer and not paid for this effort. Any help is appreciated.

@jeffhanner10 The component shelterList is not a Repeater, it is a Table . See the Table API for more information.

You have the shelterList Table connected to a dataset , so you should not be doing a query and then setting the contents of the Table . You should do a dataset filter and the Table will be updated according to the filter results.

@yisrael-wix Thanks for the info. I will try to incorporate the filter into the code.
Thanks again.

1 Like

@yisrael-wix Thank you again. That led me on the right path.

1 Like

Can I use CodeQueen’s tutorial for grid gallery instead a repeater as she has used? If so, I tried and I run with a problem at the end line, where for me it is $w(’ #ProductSearchResults ').data = res.items;. Under “.data”, is dotted lines that says "data does not exist on “ProductSearchResults”. Could you please help me here? Thank you.

@akahmed

As Yisrael has already stated above in a previous reply about the user using a table instead of a repeater…
Repeaters have a .data property which is used to set the contents of the Repeater.

If you want to use a grid gallery then the #ProductSearchResults element, which I can assume is your gallery, then you will not be using a data property, so you would need to change it to suit your gallery, which would be items.

Look in the Wix API Reference for more info in Gallery on it and the same with Image to understand about the src too.
https://www.wix.com/corvid/reference/$w.Gallery.html
https://www.wix.com/corvid/reference/$w.Image.html

Also, instead of asking on here, why not just reach out to @code-queen yourself and ask her through her own website or YouTube channel from where you are looking at either her tutorial or video about it.