As you can see the ‘collapsed on load button’ is checked …
Here the ‘collapsed on load button’ is not. This affects the tablet version too.
The only way i could fix it was to disable the mobile optimization (which i didn’t really want to do) but in so doing, the table view worked fine??
Also, whilst I have the ear of you marvellous people - can you put me out of my misery with this code query … PLEASE …
I have created a dropdown box for types of vendor and another field input box for zip code - how do I make the latter NOT accept being left blank?
Thanks so much … here’s the code …
import wixData from ‘wix-data’;
//For full API documentation, including code examples visit Velo API Reference - Wix.com
$w.onReady(function () {
//TODO: import wixData from ‘wix-data’;
});
export function searchButton_onClick() {
wixData.query(‘Tradesmen’)
.contains(‘title’, $w(‘#iAllTraders’).value)
.contains(‘postCode’, $w(‘#iPostCode’).value)
.find()
.then(res => {
$w(‘#table1’).rows = res.items;
if($w(“#table1”).collapsed) {
$w(“#table1”).expand();
}
else {
$w(“#table1”).collapse();
}
});
}
$w.onReady(function () {
$w(“#table1”).columns = [
{
“id”: “col1”,
“dataPath”: “image”,
“label”: “Photo I.D.”,
“width”: 100,
“visible”: true,
“type”: “image”
} ,
{
“id”: “col2”,
“dataPath”: “company”,
“label”: “Company”,
“width”: 120,
“visible”: true,
“type”: “text”
},
{
“id”: “col3”,
“dataPath”: “phone”,
“label”: “Phone #”,
“width”: 75,
“visible”: true,
“type”: “text”
},
{
“id”: “col4”,
“dataPath”: “web”,
“label”: “Website”,
“width”: 100,
“visible”: true,
“type”: “url”,
“linkPath”: “url”
} ,
];
});
import wixUsers from ‘wix-users’;
import wixLocation from ‘wix-location’;
$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w(“#button4”).label = “Logout”;
$w(“#button5”).show();
}
else {
$w(“#button4”).label = “Login”;
$w(“#button5”).hide();
}
} );
export function button4_onclick() {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#button4”).label = “Login”;
$w(“#button5”).hide();
} );
}
// user is logged out
else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {"mode": "login"} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query("Tradesmen")
.eq("_id", userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
"_id": userId,
"email": userEmail
};
// add the item to the collection
wixData.insert("Tradesmen", toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w("#button4").label = "Logout";
$w("#button5").show();
} )
.catch( (err) => {
console.log(err);
} );
}
}
export function button5_onclick() {
wixLocation.to(/Tradesmen/Update/{ID}${wixUsers.currentUser.id}
);
}