Smart UI Components & Libraries – Grid, Scheduler, Gantt, Kanban for Angular, React, Next.js, Vue, Blazor, JavaScript › Forums › Data Grid › problem with addRow at the beginning of the grid › Reply To: problem with addRow at the beginning of the grid
Hi,
There are several things wrong in the provided code:
objRow.cells[0].value=arrData[0]; within the addRow callback function.
objGrid.dataSource.dataSource=_data; – dataSource.dataSource is incorrect way to update a data adapter.
For adding & updating rows we have an online example: https://www.htmlelements.com/demos/grid/dynamic-rows/.
To add a row to the first position, simply modify it to use splice instead of push:
rows.splice(0,0,createRow());
or addRow method like that:
document.querySelector('smart-grid').addRow(createRow(), false);. The second parameter instructs the datagrid to add the new row to the top.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/