Hi guys im finalizing a page and iam triyng to pdf generate it, but to problem is that i pick the session data from the other page to the page i want to download the pdf but the repeater picks this data and dont display on the live dataset but shows to me that its filtering,
heres the code,
import { session } from 'wix-storage';
import wixData from 'wix-data';
$w.onReady(function () {
// Retrieve `queryResults` from session storage
let queryResults2 = JSON.parse(session.getItem('queryResults'));
console.log("Data on Session", queryResults2);
// Preprocess data to remove repetitions and handle undefined values
let uniqueMonthReport = Array.from(new Set(queryResults2.map(item => item.monthReport))).filter(Boolean);
let uniqueyYearReport = Array.from(new Set(queryResults2.map(item => item.yearReport))).filter(Boolean);
// Set the values of input1 and input2 with the unique and non-undefined values
$w('#input1').value = uniqueMonthReport.join(', '); // Join if there are multiple values
console.log("Month report", uniqueMonthReport);
$w('#input2').value = uniqueYearReport.join(', '); // Join if there are multiple values
console.log("year report", uniqueYearReport);
// Refresh the dataset to ensure the data is up to date
$w('#datasetPdfData').refresh()
.then(() => {
// Call the search function to search with the populated input values
search();
})
.catch(err => {
console.error("Failed to refresh dataset", err);
});
});
function search() {
let monthReport = $w('#input1').value;
let yearReport = $w('#input2').value;
// Ensure the input fields have values before executing the query
if (monthReport && yearReport) {
// Creating the filter
let filter = wixData.filter()
.contains("txtMonth", monthReport)
.contains("txtyear", yearReport);
// Apply the filter to both datasets
$w('#datasetPdfData').setFilter(filter)
.then(() => {
console.log("datasetPdfData is filtered");
})
.catch(err => {
console.error("Failed to set filter on datasetPdfData", err);
});
$w('#dataset1').setFilter(filter)
.then(() => {
console.log("dataset1 is filtered");
})
.catch(err => {
console.error("Failed to set filter on dataset1", err);
});
}
}
export function input2_change(event) {
search()
}
export function input1_change(event) {
search()
}
this is the code, iam filtering using the fields txtMonth and txtYear that are some of the fields on the repeater