2012-03-19 48 views
5

我有一個slickgrid,約100行。 其數據在5秒鐘內刷新,但每次更新都會導致滾動重置。 我試圖使用dataview和dataview.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() 

回答

3

我呼籲以下

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

無效和刷新也沒治好我的問題。

5

你一定要試試invalidate方法

grid.invalidate(); 

從個人的經驗,所有你需要做的刷新電網是使用在網格上提供的方法。這會更新所有內容並保留滾動。

通過刷新,你的意思是你正在替換數據,還是更新某些行?

0

我已經叫下面的代碼:

 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(); 
0

什麼工作對我來說是:

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

我使用不同的網格和視圖名稱,但這個概念圍繞着調用updateRowCount和渲染功能。

3

只使用

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

無效:平均NEAD驗證你想要哪一行 - 在這種情況下:不帶參數的行ID =所有的行