Row disappears after I edit the table

Row disappears after I edit the table

mRendermRender Posts: 151Questions: 26Answers: 13

I have to refresh the page after I edit or create a row using the editor. Can someone tell me how to fix my page so it automatically does it? This is the only page out of 4 that I've built that has this issue.

var editor; // use a global for the submit and return data rendering in the examples
 
TableTools.BUTTONS.editor_edit.formButtons.push(
{
"label": "Cancel",
"className":"btn btn-link",
"fn": function () {
this.close();
}
}); 


TableTools.BUTTONS.editor_create.formButtons.push(
{
"label": "Cancel",
"className":"btn btn-link",
"fn": function () {
this.close();
}
}); 
 
 
function isoDateString(){
    var d = new Date();
    var pad = function (n){
        return n<10 ? '0'+n : n
    }
    return d.getUTCFullYear()+'-'
        + pad(d.getUTCMonth()+1)+'-'
        + pad(d.getUTCDate())
}; 
 
 
$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        processing: true,
        seriverSide: true,
        ajax: "DataTables-1.10.0/extensions/Editor-1.3.1/examples/php/templates.php",
        "fnServerParams": function ( aoData ) {
        aoData.push( { "name": "UID", "value": "<?php echo $UID; ?>" } );
        },
        table: "#templates",
        fields: [  {
                label: "Name:",
                name: "name"
            }, {
                label: "UID:",
                name:  "UID",
                type: "hidden",
                def: '<? echo $UID; ?>'
            }
        ]
    } );
    
    
    $('#templates').DataTable( {
        dom: "Tfrtip",
        pageLength: -1,
        paging: false,
        info: false,
        idSrc: "TID",
        ajax: "DataTables-1.10.0/extensions/Editor-1.3.1/examples/php/templates.php",
        "fnServerParams": function ( aoData ) {
        aoData.push( { "name": "UID", "value": "<?php echo $UID; ?>" } );
        },
        columns: [
            { data: "name" },
          {
            data: null,
            className: "center",
            defaultContent: "Edit Template Details"
        },
          {
            data: null,
            className: "center",
            defaultContent: "Create Project Using This Template"
        }
        ],
        "order": [[ 0, 'asc' ]],
        tableTools: {
            sRowSelect: "os",
            sSwfPath: "../DataTables-1.10.0/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
            aButtons: [
                { sExtends: "editor_create", editor: editor },
                { sExtends: "editor_edit",   editor: editor },
                { sExtends: "editor_remove", editor: editor },
                "print",
                {
                    "sExtends":    "collection",
                    "sButtonText": "Save",
                    "aButtons":    [ "csv", "xls", "pdf" ]}
            ]
        },
        rowCallback: function( row, data ) {
              $('td:eq(2)', row).html( '<a class="link" href="texpenses.php?TID='+data['TID']+'">Edit Project Type Details</a>' );
              $('td:eq(1)', row).html( '<a class="link" href="createproject.php?TID='+data['TID']+'">Create Bid With Project Type</a>' );
          }
        
    } );
} );

Answers

  • allanallan Posts: 61,726Questions: 1Answers: 10,109 Site admin

    When you do an edit, what does the server return in the Ajax response? That will hopefully give us a clue as to what is happening.

    Allan

  • mRendermRender Posts: 151Questions: 26Answers: 13

    {"row":null}

  • mRendermRender Posts: 151Questions: 26Answers: 13
     ajax: "DataTables-1.10.0/extensions/Editor-1.3.1/examples/php/project.php?UID=<? echo $UID ?>",
    

    I had to put a variable in the URL that I was sending to the AJAX page. My fault, thanks Allan.

This discussion has been closed.