Inline Editor reposistions datatable .. Can i stop it ??

Inline Editor reposistions datatable .. Can i stop it ??

rob morningrob morning Posts: 30Questions: 7Answers: 1

Have an inline Editor which correctly updates a record via an ajax call BUT on completion repositions the datatable such that the first one displayed at the top of the table is the one immediately AFTER the one i've just edited .. Can I prevent this behaviour ?

Thanks ..

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,805Questions: 1Answers: 10,119 Site admin

    Yes - use the draw option of the form-options object (which you can pass into inline(). Set it to be page which will stop Editor requesting that DataTables immediately resort and filter the data based on the new data.

    Allan

  • rob morningrob morning Posts: 30Questions: 7Answers: 1

    Thanks so much .. I'll try that

  • rob morningrob morning Posts: 30Questions: 7Answers: 1
    edited October 2015

    Actually the problem is not that it repositions the datatable , it's actually hiding the row just edited .. All the other rows are displayed EXCEPT for the one just edited ..

       $(function () {
    
            var editor = new $.fn.dataTable.Editor({
                ajax: "${createLink(action: 'editLine')}",
                table: "#inventoryMasterList",
                fields: [{
                    name: 'allocatedQty',
                    data: 'allocatedQty'
                }]
            });
    
            $('#inventoryMasterList').dataTable({
                dom: 'B<"clear">lfrtip',
                buttons: [
                    {
                        extend: 'copy',
                        exportOptions: {
                            columns: [0, 1, 2, 3, 4, 5, 6, 7, 8]
                        }
                    }, {
                        extend: 'csv',
                        exportOptions: {
                            columns: [0, 1, 2, 3, 4, 5, 6, 7, 8]
                        }
                    }, {
                        extend: 'excel',
                        exportOptions: {
                            columns: [0, 1, 2, 3, 4, 5, 6, 7, 8]
                        }
                    }, {
                        extend: 'pdf',
                        exportOptions: {
                            columns: [0, 1, 2, 3, 4, 5, 6, 7, 8]
                        }
                    }
                ],
                columns: [
                    {data: 'partNumber'},
                    {data: 'serialReference'},
                    {data: 'locationCode'},
                    {data: 'inventoryQty'},
                    {data: 'allocatedQty'},
                    {data: 'inventoryStatusCode'},
                    {data: 'requiresInspection'},
                    {data: 'ranOrOrder'},
                    {data: 'tagReference'},
                    {data: 'options'}
                ],
                columnDefs: [{
                    "targets": [9],
                    "searchable": false,
                    "orderable": false,
                    "sortable": false
                }, {
                    "targets": [4],
                    "className": "editor-current"
                }],
                "lengthMenu": [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, "All"]],
                "pagingType": "simple",
                "createdRow": function (row, data, index) {
                    $('td', row).eq(9).click(function (e) {
                        var aRef = $(this);
                        var href = $('a', aRef).attr('href');
                        e.preventDefault();
                        $('#inventoryMasterFormDetails').load(href);
                        $('#inventoryMasterModal').modal('toggle');
                    });
                },
                "ajax": "${createLink(action: 'jsonList')}"
            }).on('click', '.editor-current', function (e) {
                editor.inline(this,{
                    drawType : 'page'
                });
            });
    
            decorateTable('inventoryMasterList');
    
        });
    
    

    I also use boostrap ...

  • rob morningrob morning Posts: 30Questions: 7Answers: 1
    Answer ✓

    Found it ! .. returning invalid data from ajax update .. doesn't throw any errors - just removes the row from the table .. My bad .. Thanks

This discussion has been closed.