明细表格
监听明细表变化
参考表单自定义监听
添加明细行
// 为数据源 demo 的 test_t 明细表添加一行数据
appendRow("demo", "test_t", null, {
// 字段值
pro_code: "1001",
});
// 为数据源 demo 的 test_t 明细表添加多行数据
appendRowsAsync("demo", "test_t", null, [
{pro_code: "1001" },
{pro_code: "1002" },
])
参考 API 文档:appendRow
更新明细行
// 更新数据源 aaa 的 delivery_t 明细表的指定行数据,注意传递的需要是行的Guid,而非行号
// updateRow(ds, table, rowGuid, data)
updateRow("aaa", "delivery_t", this.zcRowGuid, { pro_code: "1001" });
参考 API 文档:updateRow
删除明细行
// 删除数据源 aaa 的 delivery_t 明细表的指定行数据,注意传递的需要是行的Guid,而非行号
// removeRow(ds, table, rowGuid)
removeRow("aaa", "delivery_t", this.zcRowGuid);
参考 API 文档:removeRow
修改当前行数据
点击明细表内的按钮时,修改按钮所在行数据
return function ({ zcFormHelper }) {
// 修改当前行数据
this.zcRowData.pro_name = "hello"
}
删除所在明细行
点击明细表内的按钮时,删除按钮所在行数据
return function() {
// 获取明细表组件实例
const repeatTable = zcFormHelper.form.getFormCompRef('明细表组件ID');
// 获取当前行标识
const rowGuid = this.zcRowGuid;
// 删除当前行
repeatTable.removeRow(rowGuid);
}