-
+
c.pk).map(c => this.row[c._cn]).join('___') : ''
+ },
+ childForeignKeyVal() {
+ return this.meta && this.meta.columns ? this.meta.columns.filter(c => c._cn === this.childForeignKey).map(c => this.row[c._cn]) : ''
}
},
watch: {
@@ -347,7 +350,10 @@ export default {
this.newRecordModal = true
},
async addChildToParent(child) {
+ console.log("invoking addChildToParent ...")
+ console.log(child)
if (this.isNew && this.localState.every(it => it[this.childForeignKey] !== child[this.childPrimaryKey])) {
+ console.log(child)
this.localState.push(child)
this.$emit('update:localState', [...this.localState])
this.$emit('saveRow')
@@ -359,15 +365,26 @@ export default {
const _cn = this.childForeignKey
this.newRecordModal = false
+ // wingkwong
+
+ console.log(_cn) // CustomerEmail
+ console.log(parseIfInteger(this.parentId)) // 1
+ console.log(child[this.childForeignKey]) // user1@test.com
+ console.log(this.hm)
+ // console.log(child[`${this.hm._rtn}Read`][this.hm && this.parentMeta && this.parentMeta.columns.find(v => v.pv)._cn])
+ // console.log((this.hm && child[`${this.hm._rtn}Read`] && child[`${this.hm._rtn}Read`][this.hm && _cn]) || parseIfInteger(this.parentId))
+ console.log(child[this.childPrimaryCol])
await this.childApi.update(id, {
- [_cn]: parseIfInteger(this.parentId)
+ [_cn]: child[this.childForeignKey]
+ // [_cn]:
+ // (this.hm && child[`${this.hm._rtn}Read`] && child[`${this.hm._rtn}Read`][this.hm && _cn]) || parseIfInteger(this.parentId)
}, {
[_cn]: child[this.childForeignKey]
})
this.$emit('loadTableData')
if ((this.childListModal || this.isForm) && this.$refs.childList) {
- this.$refs.childList.loadData()
+ await this.$refs.childList.loadData()
}
},
async editChild(child) {
@@ -394,6 +411,7 @@ export default {
}
},
getCellValue(cellObj) {
+ console.log(cellObj)
if (cellObj) {
if (this.childMeta && this.childPrimaryCol) {
return cellObj[this.childPrimaryCol]
diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts
index bc77c4b808..0e40729d77 100644
--- a/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts
+++ b/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSql.ts
@@ -1279,6 +1279,7 @@ class BaseModelSql extends BaseModel {
driver.union(
parent.map(p => {
const id =
+ p[_cn] ||
p[this.columnToAlias?.[this.pks[0].cn] || this.pks[0].cn] ||
p[this.pks[0].cn];
const query = driver(this.dbModels[child].tnPath)
@@ -1296,7 +1297,7 @@ class BaseModelSql extends BaseModel {
const gs = _.groupBy(childs, _cn);
parent.forEach(row => {
row[`${this.dbModels?.[child]?._tn || child}List`] =
- gs[row[this.pks[0]._cn]] || [];
+ gs[row[_cn] || row[this.pks[0]._cn]] || [];
});
}