Topic: Datatable Update - Out of memory (many detached elements)
PrzemyslawSyc priority asked 1 day ago
Hello Team.
Could You show correct way how to update table using datatable module?
Expected behavior Replace old data in table by new one from featch rest api.
Actual behavior Many detached object and after hours - Out of memory browser crash.
Resources (screenshots, code snippets etc.)
const columns = [
{ label: 'Address', field: 'address' },
{ label: 'Company', field: 'company' },
{ label: 'Email', field: 'email' },
{ label: 'Name', field: 'name' },
{ label: 'Phone', field: 'phone' },
{ label: 'Username', field: 'username' },
{ label: 'Website', field: 'website' },
];
const asyncTable = new mdb.Datatable(
document.getElementById('datatable'),
{ columns, },
{ loading: true }
);
fetch('https://jsonplaceholder.typicode.com/users')
.then((response) => response.json())
.then((data) => {
asyncTable.update(
{
rows: data.map((user) => ({
...user,
address: `${user.address.city}, ${user.address.street}`,
company: user.company.name,
})),
},
{ loading: false }
);
});
KR Przemek
Kamila Pieńkowska staff answered 22 hours ago
Here is an example of a data update: https://mdbootstrap.com/docs/standard/data/datatables/#section-async-data
New columns used there are static but they can be async as well.
PrzemyslawSyc priority commented 10 hours ago
Thank You for quick answer.
I guess know how to use mentioned by You scripts. The question is why when I use mdb update(), browser consume a lot of memory in short time. What did I wrong? When I use datatables.net + jquery (xxx.clear() -> rows.add() -> xxx.draw() ) I don't have this type of problem.
After several seconds : Detached ×50 Detached ×542 Detached ×3439 Detached Text×6506 Detached ×50 Detached EventListener×1250 Detached ×352
- After several minutes Detached ×1161 Detached ×12763 Detached ×81203 Detached Text×149839 Detached ×20947 Detached ×1162 Detached EventListener×29050 Detached ×8136
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 7.3.2
- Device: PC
- Browser: Chrome
- OS: Windows 10
- Provided sample code: No
- Provided link: No