Can Editor insert rows that are returned after an edit of a row?

Can Editor insert rows that are returned after an edit of a row?

evandervevanderv Posts: 7Questions: 2Answers: 0

Is it possible for Editor to insert additional rows that have been added to the 'data' json array being returned from the server after an edit is done?

For example, I edit a row in such a way that will generate additional rows on the server side, I can add the row that was edited to 'data', as well as the new rows that were created, on the server side. Currently I have to do a full reload to get the new records to show, rather than them just being inserted after edit. I'd prefer not to make another ajax call just to get the new records.

Replies

  • allanallan Posts: 49,501Questions: 1Answers: 7,286 Site admin

    Yes, it should be possible to add extra rows onto the data parameter in the returned JSON. This is the code that Editor is running at that point:

            if ( json.data && (action === "create"  || action === "edit") ) {
                this._dataSource( 'prep', action, modifier, submitParamsLocal, json, store );
    
                for ( var i=0 ; i<json.data.length ; i++ ) {
                    setData = json.data[ i ];
    
                    var id = this._dataSource( 'id', setData );
                    this._event( 'setData', [json, setData, action] ); // legacy
    
                    if ( action === "create" ) {
                        // New row was created to add it to the DT
                        this._event( 'preCreate', [json, setData, id] );
                        this._dataSource( 'create', fields, setData, store );
                        this._event( ['create', 'postCreate'], [json, setData, id] );
    

    Can you show me your returned JSON?

    Allan

  • evandervevanderv Posts: 7Questions: 2Answers: 0

    Actually, Allan, I just returned the new rows separately and added them to the table. Not biggie. Thanks!

Sign In or Register to comment.