如何从datatable中的json对象获取嵌套数据

时间:2022-12-04 16:06:03

I am working on jQuery datatable in mvc, I get data through ajax call and bind to datatable as predefined syntax. The json object for ajax call response contains nested data as shown in picture.

我正在使用mvc中的jQuery数据表,我通过ajax调用获取数据并将其作为预定义语法绑定到datatable。 ajax调用响应的json对象包含嵌套数据,如图所示。

如何从datatable中的json对象获取嵌套数据

I did fetch root data successfully, but when i try to get nested data its fail to show the data.

我确实成功获取了根数据,但是当我尝试获取嵌套数据时,它无法显示数据。

oTable =$(".dataTables-example").DataTable({
    stateSave: true,
    "pagingType": "full_numbers",
    "ajax": {
        "url": "my_action_method_url",
        "type": "POST",
        "datatype": "json"
    },
    pageLength: 10,
    responsive: true,
    "columns": [
        {
            "mData": null,
            mRender: function (data) {
                return data['instituteName']; // working fine.
            }
        },
        {
            "mData": null,
            mRender: function (data) {
                return data['personalInfo.title']; // not working.
            }
        }
    ],
    "serverSide": "true",
    "order": [0, "asc"],
    "processing": "true",
    "language": {
        "processing": "Loading data..."
    }
});

1 个解决方案

#1


0  

I don't know jQuery datatable, but normally in object you can access with data.instituteName and data.personalInfo.title

我不知道jQuery数据表,但通常在对象中,您可以使用data.instituteName和data.personalInfo.title访问

#1


0  

I don't know jQuery datatable, but normally in object you can access with data.instituteName and data.personalInfo.title

我不知道jQuery数据表,但通常在对象中,您可以使用data.instituteName和data.personalInfo.title访问