Closed wangfrombupt closed 6 years ago
Currently, I modified the above code as the following to fit for my requirement of generated columns.
fetch(ajaxUrl, {
method: settings.method,
body: JSON.stringify(dataIndices),
headers: headers,
}).then(response => response.json()).then((data) => {
// copying the record from data to dataResp
Object.keys(data).forEach(function(key) {
dataResp[key] = data['row'][key];
})
dataResp[CommonConstants.GT_ROW_ID] = data['row']['id'];
editorUpdate(e, dataResp);
this.triggerAfter(EditorConstants.EDITOR_CREATE);
});
When a new record is created through Editor, only the input columns are displayed in the GT table, those generated columns (a feature supported in MySQL) are not displayed although they are returned from the server. According to the following source code in Editor.js, only the returned id matters, other columns are all ignored. In this way, the input columns which has been stored in dataResp can be displayed in GT but the generated columns do not get chance to display. .
fetch(ajaxUrl, { method: settings.method, body: JSON.stringify(dataIndices), headers: headers, }).then(response => response.json()).then((data) => { dataResp['id'] = data['row']['id']; dataResp[CommonConstants.GT_ROW_ID] = data['row']['id']; editorUpdate(e, dataResp); this.triggerAfter(EditorConstants.EDITOR_CREATE); });