如何删除backgridjs行以显示新行

How to remove backgridjs row to display new rows?

本文关键字:显示 新行 backgridjs 何删除 删除      更新时间:2023-09-26

这将向原始网格添加一组新的行:

var refreshgrid = function(){
    var grid = new Backgrid.Grid({
      columns: columns,
      collection: ter
    });
    // Render the grid and attach the root to your HTML document
   // $("#example-1-result").append(grid.remove());
    $("#example-1-result").prepend(grid.render().$el);
}

因此,每次我调用它时,它都会附加到网格中,而不是覆盖它,这正是我想要的。如何实现?

使用.html()而不是.append()/.prepend(),因为.html()用新值删除/覆盖旧值:

var refreshgrid = function(){
    var grid = new Backgrid.Grid({
      columns: columns,
      collection: ter
    });
    // Render the grid and attach the root to your HTML document
    $("#example-1-result").html(grid.render().$el);
}