I really hope someone can help me. I’m trying to add an extra row into a specified place. I retrieve the data from the repeater, added a row and then tried to set the repeater data but it didn’t work.
$w('#contextAddButton').onClick((event) => {
officerData=$w('#officerRepeater').data;
let $item = $w.at(event.context);
let repeaterId=Number($item('#repeaterId').text);
repeaterId++;
idcounter++;
officerData.splice(repeaterId, 0, {
_id: idcounter,
badgeElement: badgeElement,
badgeId: badges[badgeElement].id,
office: badges[badgeElement].title,
sameOffice: true,
}
);
officerData[repeaterId].memberId= "new memberId";
officerData[repeaterId].name= "new member name";
officerData[repeaterId].phone= "new member phone";
officerData[repeaterId].email= "new email";
$w("#officerRepeater").data = officerData;
$w("#officerRepeater").forEachItem(($item, itemData, index) => {
initRepeaterRow($item, itemData, index);
})
$w("#officerRepeater").onItemReady(($item, itemData, index) => {
initRepeaterRow($item, itemData, index);
} );
function initRepeaterRow($item, itemData, index) {
$item('#repeaterId').text = itemData._id.toString();
$item('#badgeId').text = itemData.badgeId;
$item('#memberId').text = itemData.memberId;
$item('#badgeElement').text = itemData.badgeElement;
if(itemData.sameOffice) {
$item('#officerSeparator').show();
$item('#office').hide();
} else {
$item('#office, #addOfficer').show();
$item('#roleSeparator').expand();
$item('#office').text = itemData.office;
$item('#officerSeparator').hide();
}
if (itemData.office=="Past Commodores" && itemData.roleQualifier!==undefined) {
$item('#roleQualifier').show();
$item('#roleQualifier').text = itemData.roleQualifier;
}
if (itemData.memberId==undefined) {
// testing for vacant role
}
if (itemData.boatName==undefined) {
$item('#boatNameGroup').collapse();
} else {
$item('#boatNameRepeater').text = itemData.boatName;
}
if (itemData.email==undefined) {
$item('#emailGroup').collapse();
} else {
$item('#emailRepeater').text = itemData.email;
}
if (itemData.phone==undefined) {
$item('#phoneGroup').collapse();
} else {
$item('#phoneRepeater').text = itemData.phone;
}
$item('#name').text = itemData.name;
$w("#formalPhoto").fitMode = "fit";
$item('#formalPhoto').src=itemData.formalPhoto;
}
The failure point is where I set $w(“#officerRepeater”).data to the expanded officerData. It simply doesn’t store. If I log the contents of $w(“#officerRepeater”).data it’s unchanged!
Please, please can someone point me in the right direction!
Many thanks in advance