I want to filter my dataset by matching the orderId which is unique for every entry in the dataset. I have written code for filtering but it is returning undefined. On click of the button in the repeater, that particular orderId needs to be taken and matched with the dataset and return the result. With the returned data I am going to call an API to perform other functionalities. It is my college project and
it would be great if someone could help me with this.
import {local} from 'wix-storage';
import wixWindow from 'wix-window';
import wixData from 'wix-data';
$w.onReady(function (){
console.log("getTotalPageCount() function - " +$w("#dynamicDataset").getTotalPageCount());
let records = $w("#dynamicDataset").getItems();
console.log("this is data" + records);
});
export async function onButtonClick (event) {
let $item = $w.at(event.context);
console.log($item('#orderId').value);
let orderIdToSend = $item('#orderId').value;
console.log("getTotalPageCount() function - " +$w("#dynamicDataset").getTotalPageCount());
$w("#dynamicDataset").setFilter(wixData.filter()
.eq("Order_ID", orderIdToSend))
.then((results)=>{
console.log("results - " + results);
let data = ($w("#dynamicDataset").getItems());
console.log("this is data" + data);
console.log("Dataset is now filtered by", orderIdToSend);
console.log(results.items);
})
.catch((error) => {
let errorMsg = error.message;
let code = error.code;
console.log("Catch - " + errorMsg);
});
}