How to make custom filter of dynamic dataset?

Hi guys another day another problem-

As you all know when we use a dynamic dataset it filters data on the basis of URl and currently wix doesn’t provide functionality to filter Dynamic data on the basis of dropdown (pics provided in my later posts). So I tried writing code but it didn’t work as I am unable to fetch the URL of the page and use it into my code.

URL Settings -

Code Here-

import wixData from 'wix-data';

$w.onReady( () => {
  $w("#dynamicDataset").onReady( () => 
    dateFilter();
  } );
} );

const today = new Date();

export function dateFilter(){

 let yearValue = today.getFullYear();
 let monthValue = today.getMonth();
 let dayValue = today.getDate();
 let date1 = new Date(yearValue,monthValue,dayValue,0,0,0);
 
 yearValue = today.getFullYear();
 monthValue = today.getMonth();
 dayValue = today.getDate();
 let date2=new Date(yearValue,monthValue,dayValue,23,59,59);
 
 $w("#dynamicDataset").setFilter(wixData.filter()
 .contains("remarks", "Booking")
 .between("nextServiceDate",date1,date2))
 .then(() => {
   let count = $w("#dynamicDataset").getTotalCount();
   $w('#count').text = "" + count;
 });
}

Therefore, I want to know how to make filter work dynamically.

Components On My Page -

  1. Dynamic Dataset

  2. Repeater

I have already taken help of this article couldn’t find what I wanted.

Therefore, I want to know how to make filter work dynamically.
What do you mean exactly?

When we use a dynamic page it make different pages on the basis of url and filter data as per the url.

But when we use filter code it doesn’t filter data on the basis of URL I wanna know how to filter data on URL Basis.

Can Anyone Help??

Please explain what it is you are trying to do.

If you want to query the database collection, you can either add another dataset and then set the filter, or you can query the collection using Wix Data API .

@yisrael-wix


When we work on dynamic dataset the highlighted feature is disabled .

So I tried using code to filter dynamic dataset.

But as dynamic dataset is filtered using URL (Field Name) so when we use the filter (that is made using wix code) it doesn’t filter on the basis of URL.

So I want to know how we can filter data which works dynamically as Dynamic Dataset works??

What are you using a dynamic page for? A typical use of a dynamic page is to create one page that can change its content based on the current dataset item, while keeping the same design and layout for all pages.

What are you trying to filter? Perhaps you don’t need a dynamic page for what you are trying to.

Thanks Yisrael for your efforts.

THIS IS WHAT YOU WANNA KNOW -
I have categorised my customer on the basis of Area (Service Location) this is the reason I have used dynamic pages. I want that my customer can filter between dates and can see the practise done by us during those days in that area.

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.

This is what you are here for -

import wixLocation from 'wix-location';
import wixData from 'wix-data';

export function button8_click(event) {
  dateFilter($w("#datePicker3").value, $w('#datePicker4').value);
}

export function dateFilter(today,endDate){

 let path = wixLocation.path[0].replace("-"," "); // Highlight of the code
 
 let yearValue = today.getFullYear();
 let monthValue = today.getMonth();
 let dayValue = today.getDate();
 let date1 = new Date(yearValue,monthValue,dayValue,0,0,0);
  yearValue = endDate.getFullYear();
  monthValue = endDate.getMonth();
  dayValue = endDate.getDate();
 let date2=new Date(yearValue,monthValue,dayValue,23,59,59);
  $w("#dynamicDataset").setFilter(wixData.filter()
  .eq("branch", path)
  .contains("remarks", "Booking")
  .between("nextServiceDate",date1,date2))
  .then(() => {
 let count = $w("#dynamicDataset").getTotalCount();
    $w('#count').text = "" + count;
  });
}

Help Source -