Skip to content

Commit 26eb47a

Browse files
committed
examples.table.nestedRecordFields.EditUserDialog: use the record.set() API for field changes #6262
1 parent 69a0636 commit 26eb47a

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

examples/table/nestedRecordFields/EditUserDialog.mjs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,33 @@ class EditUserDialog extends Dialog {
9999
* @param {Object} data
100100
*/
101101
onCountryFieldChange(data) {
102-
this.record.country = data.value.code
102+
// You can also access the internal setter directly:
103+
// this.record.country = data.value.code
104+
// Using the API allows bulk changes
105+
106+
this.record.set({country: data.value.code})
103107
}
104108

105109
/**
106110
* @param {Object} data
107111
*/
108112
onFirstnameFieldChange(data) {
109-
this.record['user.firstname'] = data.value
113+
// You can also access the internal setter directly:
114+
// this.record['user.firstname'] = data.value
115+
// Using the API allows bulk changes
116+
this.record.set({user: {firstname: data.value}})
117+
118+
110119
}
111120

112121
/**
113122
* @param {Object} data
114123
*/
115124
onLastnameFieldChange(data) {
116-
this.record['user.lastname'] = data.value
125+
// You can also access the internal setter directly:
126+
// this.record['user.lastname'] = data.value
127+
// Using the API allows bulk changes
128+
this.record.set({user: {lastname: data.value}})
117129
}
118130

119131
/**
@@ -124,11 +136,16 @@ class EditUserDialog extends Dialog {
124136
store = me.getStateProvider().getStore('mainStore');
125137

126138
if (data.value === false) {
127-
me.record['annotations.selected'] = false
139+
// You can also access the internal setter directly:
140+
// me.record['annotations.selected'] = false
141+
// Using the API allows bulk changes
142+
me.record.set({annotations: {selected: false}})
128143
} else {
129144
// Assuming we want to support a single row selection
130145
store.items.forEach(record => {
131-
record['annotations.selected'] = record === me.record ? data.value : false
146+
record.set({annotations: {
147+
selected: record === me.record ? data.value : false
148+
}})
132149
})
133150
}
134151
}

0 commit comments

Comments
 (0)