Hello to you all, I can not find the function that allows me to have a reset button that returns the default data from my database after a search. I only found for all to zero.
Thank you for your help
Page web site
Code:
Hello to you all, I can not find the function that allows me to have a reset button that returns the default data from my database after a search. I only found for all to zero.
Thank you for your help
Page web site
use the below code to reset the dataset filter
import wixData from “wix-data”;
$w.onReady( function () {
$w(‘#resetButton1’).onClick( function () {
$w(‘#dataset1’).setFilter(wixData.filter());
})
})
That is very helpful for increasing my knowledge in this field. academic writing
Thank you so much Mike.
Do you also know how to make a button or object not appear in the repeater if the box affiliation in the database and empty?
Can you clarify exactly what you mean, i.e give a specific example
@mikemoynihan99
My repeater refers veterinarians. I put on my repeater a button that sends to the veterinarian’s website. this button and link to a text “the site of …” then to a link also present in my database. I wish that when there is no text or link to link this button does not appear.
hmmm, try this…
$w.onReady( function () {
$w("#dataset1").onReady(() => {
$w("#repeater1").forEachItem(($w) => {
if ($w(“#linkButton1”).value === “”) {
$w(“#linkButton1”).hide();
}
})
})
})
@Mike Moynihan It does not work. In case you did not understand me I wish to have a button that sends to a link located in the database and when this link is not present the button does not appear. Thank you for your help
The Complete Code:
import wixData from “wix-data”;
export function iTitle_Keypress(event, $w) {
filter($w(‘#iTitle’).value);
}
function filter(title) {
$w(‘#dataset1’).setFilter(wixData.filter().contains(‘ville’, title));
}
export function reboot_click(event) {
(‘ville’, $w(‘#iTitle’).value = null)
$w(“#iTitle”).resetValidityIndication()
}
$w.onReady(function () {
$w(‘#reboot’).onClick(function () {
$w(‘#dataset1’).setFilter(wixData.filter());
$w("#dataset1").onReady(() => {
$w("#repeater1").forEachItem(($w) => {
if ($w(“#linkButton1”).value === “”) {
$w(“#linkButton1”).hide();
}
})
})
})
you already have a button that links to a URL in the database, correct ?
to make the button link to the URL in your database you just left click on the button and connect it to your database, choose CONNECTED TO DATA then choose LINK CONNECTS TO and select the field in your database where you have the URLs stored.
I have modified the below code slightly to hide the link buttons and verified it works:
$w.onReady( function () {
$w("#dataset1").onReady(() => {
$w("#repeater1").forEachItem(($w) => {
if ($w("# linkButton1 “).link === “”) {
$w(”# linkButton1 ").hide();
}
})
})
})
@mikemoynihan99
it’s good it works.
I put your code below that of the reset button, so that the button clear only when I clicked the reset button.
Thank you very much
@Mike Moynihan
Hello I come back to ask you, because I added the code you gave me to hide an item not attached to a link in my database but I have a problem.
To explain a little. The code you gave me and linked to a button in my repeater. I added a search bar that displays the results in the repeater, the button is hidden when the repeater is at the default result, but when I do a search the button then reappear everywhere.
Do you know where the problem may come from?
I thank you in advance for your precious help
If you have added a filter or search function then you would need to copy the same above code into that filter or search function, so that when the filter is executed the hide function is also run again.
@mikemoynihan99
I spent the whole evening trying to find
I have moved the code in several places, either it is misleading, or it does not work or only works when I’m on the default results or when I click on the search bar. I do not know what to do :/.
Can you tell me or that jokes please.
=======================
import wixData from “wix-data”;
export function iVille_click(event, $w) {
filter($w(‘#iVille’).value);
}
function filter(title) {
$w.onReady( function () {
$w(“#dataset1”).onReady(() => {
$w("#repeater7").forEachItem(($w) => {
if ($w(“#linkButton1”).link === “”) {
$w(“#linkButton1”).hide();
}
})
})
})
$w('#dataset1').setFilter(wixData.filter().contains('ville', title));
}
export function reboot_click(event, $w) {
(‘ville’, $w(‘#iVille’).value = null )
$w(“#iVille”).resetValidityIndication();}
$w.onReady( function () {
$w(‘#reboot’).onClick( function () {
$w(‘#dataset1’).setFilter(wixData.filter());
})
})