Hello, I am having issues with my checkboxes not checking in my repeater, they show what was selected when you post an entry in the database and won't let me custom check anything.
Here is my code, if you can help I would deeply appreciate it, everything I have searched online hasn't helped... Thanks!
import { local } from 'wix-storage'; import wixData from 'wix-data'; $w.onReady(function () { var sameWord = local.getItem("searchWord"); $w("#searchBar").value = sameWord; $w("#searchBar").placeholder = sameWord; // $w('#dataset1').onReady(function) () { search(); }); // }); export function searchButton_click_1(event) { search(); } function search() { wixData.query('AdMe Database') .contains('fullName', $w("#searchBar").value) .or(wixData.query('AdMe Database').contains('ad title', $w("#searchBar").value)) .or(wixData.query('AdMe Database').contains('country', $w("#searchBar").value)) .or(wixData.query('AdMe Database').contains('city / state / province', $w("#searchBar").value)) .or(wixData.query('AdMe Database').contains('price', $w("#searchBar").value)) .find() .then (res => { $w('#repeater1').data = res.items; }); } const databaseName = 'AdMe Database'; const databaseField = 'Ad Category, Sex Category, Age Category' $w.onReady(function () { $w('#checkboxGroup1').onChange((event) => { const selectedBox = $w('#checkboxGroup1').value; addItemstoRepeater(selectedBox); $w('#checkboxGroup2').onChange((event) => { const selectedBox = $w('#checkboxGroup2').value; addItemstoRepeater(selectedBox); $w('#checkboxGroup3').onChange((event) => { const selectedBox = $w('#checkboxGroup3').value; addItemstoRepeater(selectedBox); }) }); function addItemstoRepeater(selectedOption = []) { let dataQuery = wixData.query(databaseName); if (selectedOption.length > 0) { dataQuery = dataQuery.hasSome(databaseField, selectedOption); } dataQuery .find() .then(results => { const filtereditemsReady = results.items; $w('#repeater1').data = filtereditemsReady; }
the search won't work and nothing is coming up in the repeater from the collection.
I still get the same in console
this is what I get when I run the console
I am working with your edited code btw
this is what my code looks like now for the search
// --------------- MY-FUNCTIONS -----------------------------------
function search() {
wixData.query(DATABASE).contains('fullName', myValue)
.or(wixData.query(DATABASE).contains('ad title', myValue))
.or(wixData.query(DATABASE).contains('country', myValue))
.or(wixData.query(DATABASE).contains('ad description', myValue))
.or(wixData.query(DATABASE).contains('details', myValue))
.or(wixData.query(DATABASE).contains('company / name', myValue))
.or(wixData.query(DATABASE).contains('city / state / province', myValue))
.or(wixData.query(DATABASE).contains('price', myValue))
.find()
.then((res)=> {//console.log("FOUND-DATA after SEARCH-PROCESS: ", res);
$w('#repeater1').data = res.items;
return (res);
}).catch((err)=>{console.log("ERROR: ", err);});
}
here is me using the search bar and the checkboxes for the filter or repeater but nothing shows from database
connected checkboxes to dataset
here are the database categories
Will do thanks for your help
Will take a look on it in 24-hours again.
In the meanwhile to try to give more information...
1) Database? screenshot of first 3-5 rows uncluding the db-fields/db-field-ids? screenshot?
2) Dataset? (ID?/connected to?) screenshot?
3) Maybe even the setup and the flow of the actions you do ?
The more input, the more precise and faster output.
Also already checked all integrated console.logs?
What do they give back for results? (very useful info)
You know how to use CONSOLE ?
If not, press F-12 and navigate to CONSOLE, if working with GOOGLE-Browser.
You also will find all console-logs inside PREVIEW-MODE, of your WIX-EDITOR.
Nothing is coming up in the search or checkboxes.
sorry for being a noob, but the dataset won't load the repeater.
Seems like you have some issues inside your code!
1) You are using more then one --> onReady-command! --> NOT GOOD !
2) Your onClick-Functions are not closed...
$w.onReady(function(){ $w('#checkboxGroup1').onChange((event) => { const selectedBox = $w('#checkboxGroup1').value; addItemstoRepeater(selectedBox); <--- NOT CLOSED --> NOT OK! $w('#checkboxGroup2').onChange((event) => { const selectedBox = $w('#checkboxGroup2').value; addItemstoRepeater(selectedBox); <--- NOT CLOSED --> NOT OK! $w('#checkboxGroup3').onChange((event) => { const selectedBox = $w('#checkboxGroup3').value; addItemstoRepeater(selectedBox); }); // <---- CLOSED and OK !!!! });
And this one also never will work...
function addItemstoRepeater(selectedOption = []) { let dataQuery = wixData.query(databaseName); if (selectedOption.length > 0) { dataQuery = dataQuery.hasSome(databaseField, selectedOption); } dataQuery .find() .then(results => { const filtereditemsReady = results.items; $w('#repeater1').data = filtereditemsReady; }
What's that here .... ?
function addItemstoRepeater(selectedOption = []) {..........
Why you are inputing an EMPTY ARRAY into a fucntion and expecting some results?
Also using such ID'S for your --> DATABASE-FIELDS <-- is not one of the best ideas ! ....
const dbField = 'Ad Category, Sex Category, Age Category'
Was this DB-Field created by a stupid additional APP?
Ok, let's recode all your code from scratch!
import { local } from 'wix-storage'; import wixData from 'wix-data'; ///------------------------ const DATABASE = 'AdMe Database'; const dbField = 'Ad Category, Sex Category, Age Category' let mySelectedOptions = []; $w.onReady(()=> { // FIRST GETTING SOME DATA OUT OF Wix-Storage...... var searchValue = local.getItem("searchWord"); // filling your searchbar with the memorized value.... $w("#searchBar").value = searchValue; $w("#searchBar").placeholder = searchValue; $w('#searchButton').onClick(async(event)=> {console.log(event.target.id+"-clicked!"); // starting the SEARCH-FUNCTION...after a click onto the SEARCH-BUTTON.... let resData = await search(searchValue); console.log("My RESULTS = ", resData); }); $w('#checkboxGroup1').onChange((event)=> {console.log(event.target.id+"-clicked!"); const mySelectedOptions = $w('#checkboxGroup1').value; addItemstoRepeater(selectedBox); console.log(" mySelectedOptions ", mySelectedOptions); }); $w('#checkboxGroup2').onChange((event)=> {console.log(event.target.id+"-clicked!"); const mySelectedOptions = $w('#checkboxGroup2').value; console.log(" mySelectedOptions ", mySelectedOptions); addItemstoRepeater(selectedBox); }); $w('#checkboxGroup3').onChange((event)=> {console.log(event.target.id+"-clicked!"); const mySelectedOptions = $w('#checkboxGroup3').value; console.log(" mySelectedOptions ", mySelectedOptions); addItemstoRepeater(selectedBox); }); }); // --------------- MY-FUNCTIONS ----------------------------------- function search() { wixData.query(DATABASE).contains('fullName', myValue) .or(wixData.query(DATABASE).contains('ad title', myValue)) .or(wixData.query(DATABASE).contains('country', myValue)) .or(wixData.query(DATABASE).contains('city / state / province', myValue)) .or(wixData.query(DATABASE).contains('price', myValue)) .find() .then((res)=> {//console.log("FOUND-DATA after SEARCH-PROCESS: ", res); $w('#repeater1').data = res.items; return (res); }).catch((err)=>{console.log("ERROR: ", err);}); } function addItemstoRepeater(mySelectedOptions) { let dataQuery = wixData.query(databaseName); if (mySelectedOptions.length>0) {dataQuery = dataQuery.hasSome(databaseField, selectedOption);} dataQuery.find() .then((results)=> { const filtereditemsReady = results.items; $w('#repeater1').data = filtereditemsReady; }); }
This is not the end-solution --> work on it, try to understand your own code!
DO NOT FORGET TO USE THE ---> CONSOLE !!!!!!!!! IT WILL HELP YOU TO UNDERSTAND YOUR OWN CODE!!!!!