任何人都可以幫助解決這個問題。是否可以在 ng2 智能表中單擊添加新按鈕的最后一行后添加新行。如果是這樣,您能幫我解決解決方案/屬性嗎?請在下面找到代碼。
static settings= {
add: {
addButtonContent: '<i ></i>',
createButtonContent: '<i ></i>',
cancelButtonContent: '<i ></i>',
confirmCreate: true
},
edit: {
editButtonContent: '<i ></i>',
saveButtonContent: '<i ></i>',
cancelButtonContent: '<i ></i>',
},
delete: {
deleteButtonContent: '<i ></i>',
confirmDelete: false,
},
columns: {
options: {
title: 'Options',
type: 'html',
width:"30%",
editor:{
type:'list',
config:{
selectText: 'Select',
list:[{value:'Option1',title:'Option1'},
{value:'Option2',title:'Option2'},
{value:'Option3',title:'Option3'},
{value:'Option4',title:'Option4'}]
}
}
},
values: {
title: 'Values',
width:"70%",
type: 'html',
},
},
};
[從表中添加新行按鈕的影像] 1
HTML:
<ng2-smart-table [settings]="settings" [source]="settingsSource"
(createConfirm)="validateRecord($event,'cmd')">
</ng2-smart-table>
validateRecord(event,module){
if(module == 'cmd'){
if (event.newData.command !== ""){
event.confirm.resolve(event.newData);
this.emptyRecordError = false;
}
}
}
我的要求是,每次單擊“添加”按鈕時,都必須將行添加為最后一行。
uj5u.com熱心網友回復:
確保add.confirmCreate設定為true,它適合您。
添加(createConfirm)事件監聽器
<ng2-smart-table
[settings]="settings"
[source]="data"
(createConfirm)="create($event)"
></ng2-smart-table>
在回呼中追加資料,拒絕被追加的資料。
create(event: { newData: Object; source: DataSource; confirm: Deferred }) {
event.source.append(event.newData);
event.confirm.reject();
}
你需要這些進口
import { DataSource } from 'ng2-smart-table/lib/lib/data-source/data-source';
import { Deferred } from 'ng2-smart-table/lib/lib/helpers';
在這里挖掘源代碼:https ://github.com/akveo/ng2-smart-table/blob/master/projects/ng2-smart-table/src/lib/lib/grid.ts我能夠找到一個之后也可以關閉創建框
create(event: { newData: Object; source: DataSource; confirm: Deferred }) {
event.source.append(event.newData);
event.confirm.resolve.skipAdd = true;
event.confirm.resolve();
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/428383.html
標籤:javascript 有角度的 angularjs 打字稿 ng2-智能表
