1.slickgrid 删除所有数据;把主要代码放在里面 会不会只能靠自己了
//清空子表数据
var grid = new Slick.Grid("#grid_2", dataview_2, columns_2, options2);
//var grid = mc_grid_dic["grid_2"];
var dataview = grid.getData();//得到数据
var datadelete = grid.getData().getItems();//获取表格的数据
var itemId = new Array();
for (var i = 0; i < datadelete.length; i++) {
itemId.push(datadelete[i].id);//组合数据ID
}
for (var j = 0; j < itemId.length; j++) {
dataview.deleteItem(itemId[j]); //删除数据
grid.invalidate();
grid.render();//重新渲染
}
2.slickgrid 删除选中的数据;
//子表-delete行
var grid = new Slick.Grid("#grid_2", dataview_2, columns_2, options2);
$(".btndetail-delete").off("click").on("click", function () {
// var gridid = $(this).data("grid");
//var grid = mc_grid_dic[gridid];
var selected_rows = grid.getSelectedRows();//点击选中的数据
var dataview = grid.getData();//得到的数据
var itemId = new Array();
for (var i = 0; i < selected_rows.length; i++) {
itemId.push(dataview.getItem(selected_rows[i]).id);
}
for (var j = 0; j < itemId.length; j++) {
dataview.deleteItem(itemId[j]);//删除数据
grid.invalidate();
grid.render();
}
grid.getSelectionModel().setSelectedRanges([]); //取消选择
});