JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › There are a few problems. › Reply To: There are a few problems.
Hi,
The issue is caused due to JavaScript trying to apply the same object reference to all three grids. To fix the issue, you should create a copying function, so that messages is a separate object for each grid. You can insert the function below in the initGrid.js file. Then apply to each message:
function deepClone(obj) {
if (obj === null || typeof obj !== ‘object’) {
return obj;
}
if (Array.isArray(obj)) {
const arrCopy = [];
for (const item of obj) {
arrCopy.push(deepClone(item));
}
return arrCopy;
}
const objCopy = {};
for (const key of Object.keys(obj)) {
objCopy[key] = deepClone(obj[key]);
}
return objCopy;
}
And then:
messages: deepClone(messages);
Regards,
Ivan Peevski
Smart UI Team
https://www.htmlelements.com/