using Ajax - primary key question. Does the primary key field have to defined at "Id"

using Ajax - primary key question. Does the primary key field have to defined at "Id"

Joy2BeWithJoy2BeWith Posts: 1Questions: 1Answers: 0
edited June 2020 in Free community support

My AreaId comes up "unknown"

function loadDataTable() {
    dataTable = $('#areaTable').DataTable({
        "ajax": {
            "url": "/Area/GetAllAreas/",
            "type": "GET",
            "datatype": "json"
        },
        "columns": [
            {   "data": "name", "width": "20%" },
            {   "data": "description", "width": "20%" },
            //{ "data": "areanumber", "width": "20%" },
            //{ "data": "areatype", "width": "20%" },
            //{ "data": "note", "width": "20%" },
            //{ "data": "hasscheduler", "width": "20%" },
            //{ "data": "locationtype", "width": "20%" },
            //{ "data": "canrequestsupplies", "width": "20%" },
            //{ "data": "visualdisplay", "width": "20%" },
            {
                "data": "AreaId",
                "render": function (data)
                {
                    return `<div class="text-center">
                        <a href="/Area/Upsert?AreaId=${data}" class='btn btn-success text-white' style='cursor:pointer; width:70px;'>
                            Edit
                        </a>
                        &nbsp;
                        <a class='btn btn-danger text-white' style='cursor:pointer; width:70px;'
                            onclick=Delete('/Area/Delete?AreaId='+${data})>
                            Delete
                        </a>
                        </div>`;
                }, "width": "40%"
            }
        ],
        "language": {
            "emptyTable": "no data found"
        },
        "width": "100%"
    });

}

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    That probably just means it's not coming back in the data from the server - have a look at the json in the network inspector.

    If that doesn't help, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.