Hello.
I have collection named acik_pozisyonlar. I show some of the fields of this on a page. While doing this I filter the results according to a dropdown menu. To do this I use the code below. I have no problem doing this:
$w.onReady( function () {
});
import wixData from ‘wix-data’;
export function dropdown1_change(event, $w) {
wixData.query(‘acik_pozisyonlar’)
.eq(‘pozisyon_kodu_adi’, $w(‘#dropdown1’).value)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
let veriler = res.items[0];;
$w(‘#pozekletxtbox2’).value = veriler.pozisyon_adi;
$w(‘#pozekletxtbox3’).value = veriler.pozisyon_seviyesi;
$w(‘#pozekletxtbox4’).value = veriler.pozisyon_aciklamasi;
$w(‘#dropdown2’).value = veriler.pozisyonSahibiMusteri;
$w(‘#input1’).value = veriler._id;
});
}
Then I change the value of the dropdown menu to the value corresponding to the field which is on second row of the collection. Data regarding the 2nd row (the fields I want to display) is displayed successfully. Then I change only one of the text of fields. The problem arises; when I want to submit the change to the collection using a submit button. I expect the field of the 2nd row to be updated (id is correct) but the field of the first row is updated every time. My code to upadate code is below:
export function button1_click(event, $w) {
let poz_adi_kodu = $w(‘#dropdown1’).value;
let toUpdate = {
“_id”: $w(‘#input1’).value,
“pozisyon_adi”: $w(‘#pozekletxtbox2’).value,
“pozisyon_seviyesi”: $w(‘#pozekletxtbox3’).value,
“pozisyon_aciklamasi”: $w(‘#pozekletxtbox4’).value,
“pozisyonSahibiMusteri”: $w(‘#dropdown2’).value,
“pozisyon_kodu_adi”: poz_adi_kodu
};
wixData.update(“acik_pozisyonlar”, toUpdate)
.then( (results) => {
let item = results; //see item below
} )
. catch ( (err) => {
let errorMsg = err;
} );
}
My collection is connected to a normal Dataset. And my submit button is connected to the same Dataset.
I stuck on this issue. I will be glad if anyone can help.
Regards,