如何将json foriegn密钥数据加载到jquery数据表

时间:2018-01-22 17:59:51

标签: javascript jquery json datatables

This is how my JSON data is getting using the url.
[
{
    "id": 1,
    "fullName": "Menushi",
    "email": "menushi@gmail.com",
    "contact": "04567383",
    "department": {
        "id": 1,
        "departmentName": "Computing and Information System(CIS)",
        "description": "This department is regarding computer science ",
        "active": true
    },
    "imageUrl": "LCR438D8E9C68",
    "active": true,
    "file": null,
    "address": "Polonnaruwa"
},

我想在Jsondata表中显示部门名称。下面显示javascript文件的一部分。部门对象处于onetoone关系。我想在表中显示部门对象数据。

  $table.DataTable({

        pageLength: 5,
        lengthMenu: [[3, 5, 10, -1], ["3 Records", "5 Records", "10 Records", "All"]],
        ajax: {
            url: jsonUrl,
            dataSrc: ''
        },
        columns: [
            {
                data : 'imageUrl',
                mRender : function(data,type,row){
                    return '<img src="'+window.root+'/resources/images/'+data+'.jpg" class="dataTableImg">';
                }
            },
            {
                data: 'fullName'
            },
            {
                data: 'address'
            },
            {
                data: 'email'

            },
            {
                data: 'department.departmentName',

            },
            {
                data: 'contact'

            }

我已经使用上面的方式在我的javascript文件中显示部门名称..但它什么都没显示。我怎么能解决这个问题?

0 个答案:

没有答案