Dataset filter by another dataset by code in Coding with Velo

Do we have a solution for that?

If you are just using all the setup-options inside the property-panel (options) given by the dataset - → i do not know if it will be possible to genrate your wished function.

But if you use CODED-VERSION - → Then i can tell you that absolutely EVERYTHING is possible.

Ok, let’s say you have 2-DATASETS.
And you want to have your second DATASET be filtered by an selected ITEM of DATASET-1 ???

Which would be your steps?

  1. First defining the triggering-event - → when does the actions starts?
  2. After action started waht to do? → FILTERING ACTION.
  3. After FILTERING-ACTION you get some results of DATASET-1.
  4. Taking the gotten RESULT and start the second FILTERING-PROCESS on DATASET-2.
  5. Get RSULTS of DATASET-2, by a item-filtration of DATASET-1.

In velo-code-language:

$w.onReady(()=>{console.log("Here everything starts!");
	$w('#dataset1').onReady(()=>{console.log("Dataset-1 is ready!");
	$w('#dataset2').onReady(()=>{
		console.log("Dataset-2 is ready!");
		
		let currentItemData = $w('#dataset1').getCurrentItem();
		console.log("Selected-Item-Data: ",  currentItemData);		
		//----------------------------------------
		$w("#dataset1").setFilter( 		
			wixData.filter()
			.startsWith("lastName", "D")
			.ge("age","21"))
			.then((res) => {
				console.log(res);
				console.log("Dataset filtered now");
			//Does --> "res" gives you any results?
			//Not sure if it does!
			//If not you will have to go another way.
			// Then you will have to use Wix-Data-API in your part-1-code.	
			You need at this point the results of first filtering process, which you will be able to use for the second filtering process.		
			
			
				//SECOND FILTERING-PROSESS..
				
				$w("#dataset1").setFilter( 		
					wixData.filter()
					.startsWith("lastName", "D")
					.ge("age","21"))
			    .then((res) => {console.log(res);})
				.catch((err)=> {console.log(err);});
			});
		});		
	});		
});

Something like this. This code is just a quick coded EXAMPLE-CODE.
Maybe it even will not work - - > You will have to modify and optimize it.

My advice - → If you really want to code flexible features and functions, just use Wix-Data-API, without any help of any DATASETS.