Data Update in Slick Grid

纵然是瞬间 提交于 2021-02-18 22:33:50

问题


I have a slickgrid, with about 100 rows. Its data is refreshed in 5 seconds, but it is disturbing at each update the scroll is reset. I have tried to use dataview and dataview.refresh() but this time no change is reflecte to grid.

Here what I tried at each refresh:

mapMemoryTableDataView.beginUpdate();
mapMemoryTableDataView.setItems(data);
mapMemoryTableDataView.endUpdate();
mapMemoryTableDataView.refresh();

if(mapMemoryTableGrid == null)
    mapMemoryTableGrid = new Slick.Grid("#datatableMap1", mapMemoryTableDataView, columns, options);

mapMemoryTableGrid.updateRow(1)
mapMemoryTableGrid.render()

回答1:


You should definitely try the invalidatemethod

grid.invalidate();

From personal experience, all you need to do to refresh the grid is to use the invalidate method, provided on the grid. This updates everything and also preserves the scroll.

And by refresh, do you mean you are replacing the data, or updating certain rows?




回答2:


I have called the following

 mapMemoryTableDataView.beginUpdate();
    mapMemoryTableDataView.setItems(data);
    mapMemoryTableDataView.endUpdate();
    mapMemoryTableDataView.refresh();
    for (var i = 0; i < olist.length; i++) {
        mapMemoryTableGrid.updateRow(i)
    }

invalidate and refresh did not cure my problem.




回答3:


just use

gridItems.invalidate();
gridItems.render();

invalidate: mean nead to validate which row you want - in this case: no parameter row id = all row




回答4:


I have called the following code:

        mapMemoryDataView.beginUpdate();
        mapMemoryDataView.setItems(pointsRows, "id");
        mapMemoryDataView.endUpdate();
        mapMemoryDataView.syncGridSelection(pointsGrid, false);

        for (var i = 0; i < pointsRows.length; i++) {
            mapMemoryTableGrid.updateRow(i);
        }

        mapMemoryTableGrid.invalidate();
        mapMemoryTableGrid.render();



回答5:


What worked for me was:

    events[v_current_row_num].field_id = v_new_field_id;
    events_grid.updateRowCount();
    events_grid.render();

I am using different grid and view names, but the concept revolved around calling updateRowCount and render functions.



来源:https://stackoverflow.com/questions/9772207/data-update-in-slick-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!