我想用現有表格添加新行。在現有表格中添加新行
我的代碼:
onInit: function() {
var oModel = new sap.ui.model.json.JSONModel("Model/Clothing.json");
this.getView().setModel(oModel);
var table = this.getView().byId("tableid");
table.bindItems("/catalog/clothing/categories", new sap.m.ColumnListItem({
type: "Navigation",
press: function(evt) {},
cells: [
new sap.m.Text({
text: "{name}"
}), new sap.m.Text({
text: "{amount}"
}), new sap.m.Text({
text: "{currency}"
}), new sap.m.Text({
text: "{size}"
})
]
}));
table.setModel(oModel);
},
onPress: function(oEvent) {
var table = this.getView().byId("tableid");
var items = table.getSelectedItems();
for (var i = 0; i < items.length; i++) {
var data = new sap.m.ColumnListItem({
cells: [new sap.m.Text({
text: "new Row1"
}), new sap.m.Text({
text: "new row1"
}), new sap.m.Text({
text: "new row1"
}), new sap.m.Text({
text: "new row1"
})]
});
table.addItem(data);
}
},
<Table id="tableid" mode="MultiSelect" select="addRows">
<columns>
<Column>
<Text text="column1" />
</Column>
<Column>
<Text text="column2" />
</Column>
<Column>
<Text text="column3" />
</Column>
<Column>
<Text text="column4" />
</Column>
</columns>
</Table>
<Button text="Edit" press="onPress" />
這裏是我的輸出圖像
現在我想實現什麼,
- 我選擇任何複選框。
- 然後我會按
Edit
按鈕。 - 現在就按
Edit
按鈕I want to add one more row below selected checkbox row.
所以我能做到這一點。
注意現在的新行的表
[如何將新項添加到表/列表]的可能重複(https://stackoverflow.com/questions/48222553/how-to-add-a-new-item-to-a-table-list) – boghyon