2013-08-27 17 views

回答

1

您可以使用dataView.setItems(data)如下

比方說intitally你有對象的數組,你在光滑電網已綁定

var data = [ 
    {'id': 'l1', 'lang': 'Java'}, 
    {'id': 'l2', 'lang': 'JavaScript'}, 
    {'id': 'l3', 'lang': 'C#'}, 
    {'id': 'l4', 'lang': 'Python'} 
      ]; 

然後你就可以在陣列在推你想盡可能多的項目如下

data.push({ 
    "id" : "l5", 
    "lang" : ".net" 
}); 

然後使用 'dataView.setItems()' 你麪包車更新網格

// This will fire the change events and update the grid. 
dataView.setItems(data); 

OR 

// You can populate the dataview with new array list if you have any 
dataView.setItems(newArray); 
3

我假設你的目標是防止用戶界面更新(昂貴的),同時更新多個行:

function updateItems (itemsToUpdate) { 
    dataView.beginUpdate(); // tell your DataView to prevent re-rendering the SlickGrid on every change 
    itemsToUpdate.forEach(function(item){ // iterate over each item in the array 
    dataView.updateItem(item.id, item) // update the item's data 
    }); 
    dataView.endUpdate(); // tell DataView to re-render the SlickGrid with any changes 
}