Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82755

Nested Editing with no Ajax URL causes data to be erased

$
0
0

Link to test case: https://live.datatables.net/taxowela/8/edit

Nested Editing - non Ajax

Setup

Similar to the Nested editing - single selection example.
- A main table
- A main table editor
- A editor for the editor

The main editor has a field that is a datatable.

The difference between my test case and the example is that my data source is a javascript array local to the code. (In my real case I get the data from a server but then must transform the data before adding it to the table.)

Error messages shown

After editing an item in the table that is an editor field and submitting the update, there's a console error output because the datatables __reload function can't handle the case where there is no ajax url.

** TypeError: null is not an object (evaluating 'ajax.url') **

From the __reload function:

if ( _fnDataSource( settings ) == 'ssp' ) {
    _fnReDraw( settings, holdPosition );
}
else {      <----- This assumes there is an Ajax URL (and calls _fnBuildAjax)
    _fnProcessingDisplay( settings, true );

    // Cancel an existing request
    var xhr = settings.jqXHR;
    if ( xhr && xhr.readyState !== 4 ) {
        xhr.abort();
    }

    // Trigger xhr
    _fnBuildAjax( settings, {}, function( json ) {
        _fnClearTable( settings );

        var data = _fnAjaxDataSrc( settings, json );
        for ( var i=0, ien=data.length ; i<ien ; i++ ) {
            _fnAddData( settings, data[i] );
        }

        _fnReDraw( settings, holdPosition );
        _fnInitComplete( settings );
        _fnProcessingDisplay( settings, false );
    } );
}

This is being called on the Main Table for some reason.

How to reproduce

  • Load the test case page
  • Select one of the lines, and then the Edit button
  • Select a line in the Employees field (the datatable), and then the Edit button
  • Change some data, click the Update button

Description of problem

Editing the main table row that was previously edited displays "No data available in table". That table row has now been cleared. The reason seems obvious, since the __reload function failed, so I'm wondering if I'm missing some configuration of event handling that should be done to bypass the default handling.


Viewing all articles
Browse latest Browse all 82755

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>