刪除grid中的一條記錄或者多條記錄
阿新 • • 發佈:2019-02-14
//刪除資料
function delgrid(){
/*
//刪除grid中的一條記錄
var record = grids.getSelectionModel().getSelected();
grids.store.remove(record);
*/
//刪除多條記錄
var records = grids.getSelectionModel().getSelections();
if(records.length == 0){
sofa.alert("請選擇刪除的行號!");
}else{
for(var i = 0;i<records.length;i++ ){
grids.store.remove(records[i]);
}
}
var datass=grids.getStore().data.items;
var types="";
var typeNames="";
for(var i=0;i<datass.length;i++){
if(i==0){
types=datass[i].data.type;
typeNames=datass[i].data.typeName;
}else{
types += "," + datass[i].data.type;
typeNames += "," + datass[i].data.typeName;
}
datass[i].set("id",i);
}
type.clear();
type.setValue(types);
type.setRawValue(typeNames);
grids.view.refresh();
}
function delgrid(){
/*
//刪除grid中的一條記錄
var record = grids.getSelectionModel().getSelected();
grids.store.remove(record);
*/
//刪除多條記錄
var records = grids.getSelectionModel().getSelections();
if(records.length == 0){
sofa.alert("請選擇刪除的行號!");
}else{
for(var i = 0;i<records.length;i++ ){
grids.store.remove(records[i]);
}
}
var datass=grids.getStore().data.items;
var types="";
var typeNames="";
for(var i=0;i<datass.length;i++){
if(i==0){
types=datass[i].data.type;
typeNames=datass[i].data.typeName;
}else{
types += "," + datass[i].data.type;
typeNames += "," + datass[i].data.typeName;
}
datass[i].set("id",i);
}
type.clear();
type.setValue(types);
type.setRawValue(typeNames);
grids.view.refresh();
}