0

I have an ajax Datatable which calls BE API to retrieve data:

tableColumns = 
[
    {"data": "Id","name": "Id","title": "Id"},
    {"data": "Code", "name": "Code", "title": "Code"},
    {"data": "DisplayCode", "name": "DisplayCode","title": "DisplayCode"},
    {"data": "Name","name": "Name","title": "Name"},
    {"data": "Country","name": "Country", "title": "Country"},
    {"data": "BackColor","name": "BackColor","title": "BackColor"},
    {"data": "ForeColor", "name": "ForeColor","title": "ForeColor"}
]

table.DataTable(
    {
        ajax: {
            url: tableurl,
            type: "POST",
        },
        dom: '<fB<t>lip>',
        buttons: true,
        processing: true,
        serverSide: true,
        filter: true,
        columns: tableColumns
})

Debbuging screenshot of my BE method returned json: enter image description here

After investigating the response on the browser the columns first letter become lower case e.x backColor, displayCode. Why is this happens ? Is this something that Datatable Api mechanisms do by default ? enter image description here

pikk
  • 837
  • 5
  • 21
  • 38
  • I think the issue is with your backend could you check the Json(returnObj) is transforming they keys i think could you check that – Sanu Khan Mar 23 '23 at 10:13
  • The first screenshot is the backend debug, as you can see the names e.x "ForeColor" and "DisplayCode" are corectly with first letter capital – pikk Mar 23 '23 at 10:15
  • DataTables does not cause this (and neither does jQuery, as far as I am aware). Are you using C#/.NET? If so, take a look at [API Json response to C# Object with capital case properties first letter](https://stackoverflow.com/a/59282215/12567365). – andrewJames Mar 23 '23 at 11:36
  • If that does not help, please provide a [mre]. – andrewJames Mar 23 '23 at 11:36

0 Answers0