I use repeater and connect to database.
The repeater setting mode read & write.
If I put the button in the repeater , it work.
But put outside repeater, it dosen’t work.
Is there the way only use 1 button change the database?
I use repeater and connect to database.
The repeater setting mode read & write.
If I put the button in the repeater , it work.
But put outside repeater, it dosen’t work.
Is there the way only use 1 button change the database?
Hi nanami,
I don’t know if it will work but try adding a button to the page
Then in the onClick event add this code
$w(“#yourDataset”).save()
@volkaertskristof Thank you for your answer.
I tried it but it not work…
err
ave operation failed: DatasetError: Operation (save) not allowed during save
Is the buttom connected to your dataset?
If so, disconnect it and then use the save
@volkaertskristof Thank you for your reply.
I try disconnect, but It’s not work.
Not err
but No reaction.
I want use Automation mail system.
So I need this,
Can anyone help me?
Sadly enough i haven’t worked alot with dynamicdatasets yet.
I hope someone else might be able to help you.
Please help me…
Well, first of all, i would suggest you to work always the —> onReady()-way, instead of using single located export-functions for event-handlers.
What do i mean?
$w.onReady(()=>{
And all the Rest of your CODE belongs inside the onReady-part/inside the curly-brakets.
}));
When working with a DATASET, you also need the second onReady-part—> $w(‘#myDataset’).onReady(()=>{});
$w.onReady(()=>{
$w(‘#myDataset’).onReady(()=>{
//all the test of your code inside…
});
});
Example-Save-Function of DATASETS from API-Docs:
$w.onReady( () => {
$w(“#myDataset”).onReady( () => {
$w(“#myDataset”).save()
.then( (item) => {
let fieldValue = item.fieldName;
} )
.catch( (err) => {
let errMsg = err;
} );
} );
} );
Disconnect your dataset connection, because you do all by code.
@russian-dima Thank you for your reply.
I tried it.
But onclick event can’t use in the onReady handlers.
Don’t you use onclick event?
If so please tell me the code.
But onclick event can’t use in the onReady handlers.
Something like this one… not sure…
let DATASET = "#dataset1"
$w.onReady(()=> {console.log("Page is ---> READY...")
$w(DATASET).onReady(()=> {console.log("DATASET is ---> READY...")
$w('#myButtonIDhere').onClick(()=>{console.log("Button-Clicked!!!")
$w(DATASET).setFieldValues( {
"what-ever DATAFIELD-1 here": "what-ever VALUE-1 here",
"what-ever DATAFIELD-2 here": "what-ever VALUE-2 here",
"what-ever DATAFIELD-3 here": "what-ever VALUE-3 here",
"what-ever DATAFIELD-4 here": "what-ever VALUE-4 here",
"what-ever DATAFIELD-5 here": "what-ever VALUE-5 here"
});
$w(DATASET).save(); console.log("Save-process running...")
});
$w(DATASET).onAfterSave(()=> {console.log("After save running...");});
});
});
@russian-dima Thank you again!
I tried the code.
It’s work for the button.
but Save only top of the repeater.
I want save all data in the repeater
Is there the way only use 1 button change the database?
my code
let DATASET = “#dynamicDataset”
$w . onReady (()=> { console . log ( “Page is —> READY…” )
$w ( DATASET ). onReady (()=> { console . log ( “DATASET is —> READY…” )
$w ( ‘#button268’ ). onClick (()=>{ console . log ( “Button-Clicked!!!” )
$w ( DATASET ). setFieldValues ( {
“url” : “URL” ,
“number” : “Number”
});
$w ( DATASET ). save (); console . log ( "Save-process running..." )
});
$w ( DATASET ). onAfterSave (()=> { console . log ( "After save running..." );});
});
});
@nanami
You will have to elaborate more of your project.
-Do you use several DATASETS ?
(-dataset1, dataset2, dataset3, dataset4, dataset5 and so on…?)
-How do look like the connected DATABASES?
Screenshots possible?
-You will have first to collect all wished data from all wished DATASETS and generate either an ARRAY or, even better an OBJECT, pushing all collected DATA into the ARRAY or OBJECT.
-Then you can generate the FIELDSVALUES for SAVING-PROCESS of your DATASET.
Or you go another way using WIX-DATA. Going this way, you won’t need any DATASETS.
ADDITIONAL-QUESTION: Do you also use REPEATER(s) ???
As i can see in your first post → YES you are using a REPEATER!
The setup of your project is still not completely clear for me.
-How much DATABASES are involved?
-DATABASE-A (Fields: a,b,c,d…)
-DATABASE-B (Fields: a,b,c,d…)
-DATABASE-C (Fields: a,b,c,d…)
-DATABASE-D (Fields: a,b,c,d…)
Attention → i am not talking about DATASETS! → DATABASES!
Now, what is connected to what?
How much DATASETS do you have?
How much REPEATERS are used?
What is connected to what?
Are DYNAMIC-DATASETS involved?
How much REPEATERS are involved?
What is connected to what?
@russian-dima Thank you for your reply.
I use only 1 database.
Use repeater.
the all information connect to the database.
I want save information in this repeater only 1 button.
Not dynamic pages.
This is Why I use only 1 button because when the button clicked send automation mail.
Ok, now your setup is clear…
DATABASE + REPEATER —> connected to DATASET
CODE : Something like this one… (replace all needed IDs of all your elements)
let REPEATER = "#repeater1"
let DATASET = "#???????????????????????????????????????????"
$w.onReady(()=> {console.log("Page is ---> READY...")
$w(REPEATER).onReady(($item, itemData, index)=> {
$w('#button268').onClick(()=>{console.log("EXTERN-Button-Clicked!!!")
$w(DATASET).setFieldValues( {
"url": $item('#aaaaaaaaaa').value,
"number": $item('#bbbbbbbbbb').value,
"xxxxxx": $item('#cccccccccc').value,
"yyyyyy": $item('#dddddddddd').value,
"zzzzzz": $item('#eeeeeeeeee').value,
"wwwwww": $item('#ffffffffff').value,
});
$w(DATASET).save(); console.log("Save-process running...")
});
$w(DATASET).onAfterSave(()=> {console.log("After save running...");});
});
});
But i fear this one also won’t work like you expect it. Your Submit-Button must be INSIDE-REPEATER, too (inside-Repeater-Container), otherwise your REPEATER won’t be able to recognize which of your items has been selected!
After you find out that my fears have come true, do the following changes…
$w('#button268').onClick(()=>{console.log("EXTERN-Button-Clicked!!!")
…to this…
$item('#button268').onClick(()=>{console.log("INTERN-Button-Clicked!!!")
BUT WAIT !!! → “#dynamicDataset” ??? What ?
So what is it now??? DYNAMIC <— or —> NON-DYNAMIC
@russian-dima Thank you so much.
In side “#???” is dataset name isn’t it?
the dataset name is dynamicDataset.
default name.
And I tried your code…but still not work…; ;
err
TypeError: $w(…).onReady is not a function
@volkaertskristof This is probably happening because he connected the save button to the dataset to save it, so the save function is invoked twice, once via the dataset, and once via the onClick event handler.
@nanami
I think Ninja messed up some code.
Instead of
$w ( REPEATER ). onReady (( $item, itemData, index ) => {
use
REPEATER . onReady (( $item, itemData, index ) => {
and evrywhere it says
$w ( DATASET )
change it to
DATASET
@volkaertskristof @russian-dima the repeater’s ready function is onItemReady( )
Hi there …
You’re overcomplicating it, actually, it’s very simple. Just save the dataset, if the input fields are connected to the dataset, you don’t need to set any values, just save the dataset, with the code below, or you can save it by connecting the button to the dataset (outside the repeater) and set its action to “Save”.
NOTE: Make sure to run this code after the page and the dataset are ready.
// The button's dynamic on click event handler
$w('#saveData').onClick(() > {
$w('#dataset').save();
})
I’m still confused as to why your code includes a “#dynamicDataset” while you’re using a regular one to display items?