GigaTables / reactables

GigaTables is a ReactJS plug-in to help web-developers process table-data in applications and CMS, CRM, ERP or similar systems.
MIT License
144 stars 30 forks source link

New record's generated columns cannot display #98

Closed wangfrombupt closed 6 years ago

wangfrombupt commented 6 years ago

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); });

wangfrombupt commented 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);
        });