Hello, i got a datatable component on my form. It has 7 columns: Category, CurrentLimitCZ, LimitCZ, CurrentLimitSK, LimitSK, CurrentLimitPL, LimitPL. I fetch a Json(multiple line text) from list and show current limits in datatable if the category match. The current limits shows in a datatable, but i got a problem when i click into some column and then try to click into another one i got this error.
Here is my js code for datatable:
function setCurrentLimitsInNewLimitsTable() {
const newLimitsTable = fd.control('DataTable1');
if (!newLimitsTable) return;
pnp.sp.web.lists.getByTitle("Limits").items
.select("JsonMSR")
.top(1)
.get()
.then(function(items) {
if (items.length === 0) return;
const currentLimitsJson = items[0].JsonMSR;
let currentLimits = [];
try {
currentLimits = JSON.parse(currentLimitsJson);
} catch (e) {
console.error("Invalid JSON in current limits:", e);
return;
}
const tableRows = newLimitsTable.value.map(row => {
const matched = currentLimits.find(c => c.Category === row.Category);
return {
...row,
CurrentLimitCZ: matched?.LimitCZ || 0,
CurrentLimitSK: matched?.LimitSK || 0,
CurrentLimitPL: matched?.LimitPL || 0,
LimitCZ: 0,
LimitSK: 0,
LimitPL: 0
};
});
newLimitsTable.value = tableRows;
})
.catch(function(error) {
console.error("Error fetching limits:", error);
});
}
fd.spRendered(function () {
setTimeout(setCurrentLimitsInNewLimitsTable, 100);
...rest of another code
Thank you in advance.