Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

Data Table Editor

$
0
0

Hi,

I'm experiencing an issue with the DTE that I'm hoping is something silly on my part.

The problem is that the editing field does not close initially after submitComplete fires.
The field successfully updates, and the data returns in the required format (see below)

However the field does not close itself.
As seen here - http://imgur.com/mXQFNrw

If I then click on another row in the table, the field does close but it collapses and the cell data is removed.
As seen here http://imgur.com/XTsbZ1p

This is occurring in a bootstrap modal if that makes a difference in Chrome, Edge & IE

Javascript used to trigger this is included below.

Any assistance you can provide would be much appreciated.

// Server response after edit
{
  "data":{
    "TotalRecords":0,
    "Id":209,
    "Name":"AP Pit 1_T11",
    "CreatedOn":"\/Date(1461852000000)\/",
    "CreatedBy":4,
    "IsDeleted":false,
    "UpdatedOn":
    "\/Date(1465518020070)\/"
  }
}


// Set up the modal
$(document).ready(function () {
    debugger;
    MapId = $("#Id").val() !== "" ? $("#Id").val() : 0;

    // Configure the editor for locations
    unusedLocationsDataTableEditor = new $.fn.dataTable.Editor({
        ajax: {
            type: "PUT",
            url: "/Location/UpdateLocation"
        },
        idSrc: "Id",
        table: "#mapUnusedLocationsTable",
        fields: [
            {
                name: "Name"
            }
        ]
    });

    // Configure the unused location data table
    unusedLocationsDataTable = $("#mapUnusedLocationsTable").DataTable({
        processing: false,
        serverSide: false,
        ajax: {
            url: "/Map/GetMapUnusedLocations/" + MapId,
            type: "GET"
        },
        idSrc: "Id",
        dom: "rfti",
        paging: false,
        scrollY: "250px",
        scrollCollapse: false,
        select: {
            style: "os",
            selector: "td:first-child"
        },
        order: [1, "asc"],
        columns: [
            {
                data: null,
                defaultContent: "",
                className: "select-checkbox",
                orderable: false,
                searchable: false
            },
            {
                data: "Name",
                orderable: true
            }
        ]
    });

    // Handle submission responses for location edits as we're returning non standard error responses
    unusedLocationsDataTableEditor.on("submitComplete", function (e, json) {
        if (json.error) {
            unusedLocationsDataTableEditor.field("Name").error("Error: " + json.error);
        } else {
            alertify.success("Location Updated");
        }
    });

    // Enable double click to edit existing locations
    unusedLocationsDataTable.on("click", "tbody td:not(:first-child)", function () {
        unusedLocationsDataTableEditor.inline(this);
    });

Viewing all articles
Browse latest Browse all 2364

Trending Articles