I’m also having trouble get my search functions to work now on the front end that I don’t have the dataset there. Any suggestions there would be helpful:
here is my webpage link: https://www.dgs.org/membership-directory-coded
here is my current front end code:
import { getRocksData } from ‘backend/callData’ ;
$w . onReady ( async function () {
$w ( "#table1" ). columns = [{
"id" : "col1" ,
"dataPath" : "title" , // matches field key from collection
"label" : "Name" ,
"width" : 100 ,
"visible" : **true** ,
"type" : "Text" ,
},
{
"id" : "col2" ,
"dataPath" : "lastName" , // matches field key from collection
"label" : "Last Name" ,
"width" : 100 ,
"visible" : **true** ,
"type" : "Text" ,
},
{
"id" : "col3" ,
"dataPath" : "email" , // matches field key from collection
"label" : "Email" ,
"width" : 100 ,
"visible" : **true** ,
"type" : "Text" ,
},
{
"id" : "col4" ,
"dataPath" : "address" , // matches field key from collection
"label" : "Address" ,
"width" : 100 ,
"visible" : **true** ,
"type" : "Text" ,
}
];
//SEARCH BUTTON TRIGGER
$w ( “#searchButton” ). onClick ( function () {
search ();
});
//ENTER KEY TRIGGER
$w ( "#searchBar" ). onKeyPress ( function ( event ) {
if ( event . key === "Enter" ) {
search ();
}
});
$w ( "#searchBar2" ). onKeyPress ( function ( event ) {
if ( event . key === "Enter" ) {
search ();
}
});
//dropdown click trigger
$w ( "#dropdown1" ). onClick ( function () {
search ();
});
//SEARCH FUNCTION
function search () {
$w ( data ). onReady ( function () {
$w ( data ). setFilter ( data . filter (). contains ( 'membership' , String ( $w ( '#dropdown1' ). value ))
. and ( data . filter (). contains ( "title" , String ( $w ( '#searchBar' ). value )))
. and ( data . filter (). contains ( "lastName" , String ( $w ( '#searchBar2' ). value )))
. and ( data . filter (). eq ( 'hide_in_search' , Boolean ( **false** ))))
$w ( "#clearFilter" ). show ();
})
}
//CLEAR FILTER
$w ( "#clearFilter" ). onClick ( function () {
$w ( "#dropdown1" ). value = **undefined** ;
$w ( "#searchBar" ). value = **undefined** ;
$w ( "#searchBar2" ). value = **undefined** ;
$w ( "#clearFilter" ). hide ();
search ()
});
let data = **await** getRocksData ()
$w ( '#table1' ). rows = data
})