我正在借助以下内容更新 slickgrid: dataView.updateItem(args.item.id, row); 但是我有许多行要同时更新。那么如何在 slickgrid 的数据视图中更新行数组?
问问题
2673 次
2 回答
3
我假设您的目标是在更新多行时防止 UI 更新(昂贵):
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
}
于 2013-08-27T18:19:44.723 回答
1
您可以使用dataView.setItems(data)
如下
让我们说你有一个对象数组,你已经绑定在光滑的网格中
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()'你van更新你的网格
// 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);
于 2013-08-27T16:30:15.563 回答