I am trying to create a simple filter on BookDataset where user inputs the phone number and the Bookdataset connected to repeater populates the book details.
This is the code
$w( ‘#Booklistdataset’ ).setFilter(wixData.filter().eq( ‘PhoneNumber’ , $w( ‘#PhonenumberLookup’ ).value)) ;
when the page is loaded , I get the following error
Unhandled rejection Error: WDE0025: The collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor. at errorWithCode (/elementory/g/backend/wix/node_modules/@wix/wix-data-provider/node_modules/@wix/wix-data-core/lib/errors.js:321:15) at wixDataError (/elementory/g/backend/wix/node_modules/@wix/wix-data-provider/node_modules/@wix/wix-data-core/lib/errors.js:281:10) at /elementory/g/backend/wix/node_modules/@wix/wix-data-provider/lib/utils/get-not-deleted-schema.js:14:29
When I enter a phone number that has records in the collection, the repeater is not visible.
Where am I doing wrong ? please help. I am unable to proceed
Hi
use the function onReady before setting a filter.
here is the link for it
https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#onReady
kristof.
Thanks Kristof .
it did not work
I can see the message “The dataset is ready” in the console. But the repeater is still not populated.
here is the code
export function GoButton_click(event) {
$w( “#Booklistdataset” ).onReady( () => {
console.log( “The dataset is ready” );
} );
$w( ‘#Booklistdataset’ ).setFilter(wixData.filter().eq( ‘PhoneNumber’ , $w( ‘#PhonenumberLookup’ ).value)) ;
}
Hi @sumruxreach
You have to put the code to filter the dataset in to onReady function. like this.
exportfunction GoButton_click(event) { $w("#Booklistdataset").onReady( () => {
$w('#Booklistdataset').setFilter(wixData.filter().eq('PhoneNumber', $w('#PhonenumberLookup').value))
console.log("The dataset is ready");
} );
}
the meaning of the onReady function is to run the code inside the function when the dataset is ready.
meanwhile when it is still loading “getting ready” it goes trough the next code.
so in the code you provided you added the onReady function.
its bussy loading it.
starts filtering
and after it is filtered it is probably done loading.
you can also test it buy adding multiple console.log()
1 before the on ready
1 inside the on ready
1 after the onready.
exportfunction GoButton_click(event) {
console.log("1");
$w("#Booklistdataset").onReady( () => {
console.log("2");
} )
console.log("3");
}
will return
//1
//3
//2
Still not working . I tried this getting error after the "After on ready " message
the phonenumber I am looking for is in the dataset.
When form loads the repeater displays first few rows of the collection
console.log( "Before The On ready" )
$w( "#Booklistdataset" ).onReady( () => {
$w( '#Booklistdataset' ).setFilter(wixData.filter().eq( 'PhoneNumber' , $w( '#PhonenumberLookup' ).value))
console.log( "The dataset in on ready" );
} );
console.log( “After on ready” )
Before The On ready
The dataset in on ready
After on ready
Unhandled rejection Error: WDE0025: The collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor. at errorWithCode (/elementory/g/backend/wix/node_modules/@wix/wix-data-provider/node_modules/@wix/wix-data-core/lib/errors.js:321:15) at wixDataError (/elementory/g/backend/wix/node_modules/@wix/wix-data-provider/node_modules/@wix/wix-data-core/lib/errors.js:281:10) at /elementory/g/backend/wix/node_modules/@wix/wix-data-provider/lib/utils/get-not-deleted-schema.js:14:29
Hi,
i can’t currently see the problem.
what you can do now is :
- log your phonenumber to your console to see if it is correct.
2)look if the typeof the phone number is equal to the one in the database.
u can use parseInt($w(“#PhonenumberLookup”).value) to change it from a string to an integer.
- add some screenshots from the database, inputfield and code. so we can check if there is anything wrong
- wait for a moderator to ask for your website so he can take a look.
kristof.
Thanks Kristof. I tried points 1 and 2. Did not hep. The phone number is text field in both page and the database
Here is the database
Here is the page on load
Here is page with phone number entered
Hi,
I’m sorry for the late response.
i think i found the mistake.
if you look in your databae the column is named PhoneNumber (with 2 capital letters in it)
however when you go to the database and you look at the column value name it would probably be phoneNumber (first capital of a word will be changed to lowercase)
if you change this in your .eq() filter it should work i think.
kristof.