DataTables error: requested unknown parameter

When using Datatables, if the configured column field is missing in the json data returned in the background, an error of requested unknown parameter will be reported. For example

, four columns are configured in the front-end column:

{"title": "name", 'data': 'name'},
{"title": "SMS platform username", 'data': 'username'},
{"title": "information", 'data': 'content'},
{"title": "extension number", 'data': 'ext'},
but the json data returned in the background [{name:xxx,username :yyy,content:zzz}] has no ext field.
There are two solutions:
1. The back-end returns data to complete
2. The front-end sets the default value so that Datatables will not report an error.
Because mybatis is used in the background, the returned data type is map, and mybatis automatically hides the null data, resulting in missing fields. It is not easy to modify.
So use method 2: change the front end to:
{"title": "name", 'data': 'name',"defaultContent": ""},
{"

{"title": "Extension number", 'data': 'ext', "defaultContent": ""},
add defaultContent attribute
Reference : https://datatables.net/reference/option/columns.defaultContent

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326572153&siteId=291194637