Hi everyone,
I’ve hit a really silly roadblock.
I have a Dynamic Page with a couple of Multi-state boxes, a search bar and a Repeater.
Everything works well, except I seem completely unable to filter my dataset. I’m filtering the “Wix” way, by adjusting the settings of the Dataset to exclude certain values, but it simply doesn’t work,
My code is below (although I’ve applied the filters traditionally) does anyone have any ideas please?
import wixData from “wix-data” ;
$w.onReady( function () {
$w( “#button1” ).onClick(() => {
$w( “#statebox8” ).changeState( “Open” );
});
$w( “#button3” ).onClick(() => {
$w( “#statebox8” ).changeState( “Closed” );
});
$w( “#button5” ).onClick(() => {
$w( “#statebox9” ).changeState( “Open1” );
});
$w( “#button6” ).onClick(() => {
$w( “#statebox9” ).changeState( “Closed1” );
});
$w.onReady( function () {
$w( ‘#repeater’ ).collapse()
$w( “#searchbutton” ).onClick(()=>{
$w( ‘#repeater’ ).expand()
$w( ‘#repeater’ ).show()
$w( “#dynamicDataset” ).setFilter(wixData.filter()
.contains( “title” , $w( “#searchbox” ).value));
});
});
});
You have two page onReady() event handler functions. The second one is inside the first one. Since onReady() only runs once - when the page is ready - the second one never runs.
Gotcha, I’ll have a fiddle thank you
Hi Ysrael / all,
I’m glad to have tidied that up, but it hasn’t fixed the issue.
The code and a screenshot are below. I’m trying to ignore certain rows in my dataset using the filter, in this case I’m trying to ignore any rows where the Column “Independent Copy” is empty.
import wixData from “wix-data” ;
$w.onReady( function () {
$w( “#button1” ).onClick(() => {
$w( “#statebox8” ).changeState( “Open” );
});
$w( “#button3” ).onClick(() => {
$w( “#statebox8” ).changeState( “Closed” );
});
$w( “#button5” ).onClick(() => {
$w( “#statebox9” ).changeState( “Open1” );
});
$w( “#button6” ).onClick(() => {
$w( “#statebox9” ).changeState( “Closed1” );
});
$w( ‘#repeater’ ).collapse()
$w( “#searchbutton” ).onClick(()=>{
$w( ‘#repeater’ ).expand()
$w( ‘#repeater’ ).show()
$w( “#dynamicDataset” ).setFilter(wixData.filter()
.contains( “title” , $w( “#searchbox” ).value));
});
});

I’m wondering if this is to do with the page being Dynamic? If so I can always have a reshuffle
I’m sorry, but I really don’t understand what you are trying to accomplish. You have a filter in the dataset, and then you set another filter in code. What do you want to happen? And what is in fact happening?
Sorry Ysrael. The search words perfectly. Maybe I’m misunderstanding the function of the filter.
I have a large dataset and I only want to provide this search access to part of it. I want to filter out part of this dataset, not from people’s search but as a default on this page.
I have all the data tagged, so was hoping I could simply filter the dataset so it only pulls from certain tagged rows
To put this another way, I have a dataset full of data from both Grammar Schools and Independent schools. When the search is run I only want to Repeater to display results from Grammar Schools.
I’m trying to achieve this, basically
https://support.wix.com/en/article/about-filtering-and-sorting-collection-content-displayed-in-page-elements
The search bar works perfectly, it’s just that currently it displays results from the whole database, not just the Grammar element
I’ve worked this out.
For the benefit of anyone who has a similar problem, I amended the code to filter out certain fields using the .ne command
import wixData from “wix-data” ;
$w.onReady( **function** () {
$w( "#button1" ).onClick(() => {
$w( "#statebox8" ).changeState( "Open" );
});
$w( "#button3" ).onClick(() => {
$w( "#statebox8" ).changeState( "Closed" );
});
$w( "#button5" ).onClick(() => {
$w( "#statebox9" ).changeState( "Open1" );
});
$w( "#button6" ).onClick(() => {
$w( "#statebox9" ).changeState( "Closed1" );
});
$w( '#repeater' ).collapse()
$w( "#searchbutton" ).onClick(()=>{
$w( '#repeater' ).expand()
$w( '#repeater' ).show()
$w( "#dynamicDataset" ).setFilter(wixData.filter()
.ne( "examType" , "Independent" ).contains( "title" , $w( "#searchbox" ).value));
});
});
Since you are setting the filter from the search bar using code, just add Grammar school to the filter as well.
@yisrael-wix Just saw this - thank you