如何在td元素的属性中添加ajax数据

时间:2018-01-23 12:59:03

标签: javascript jquery ajax datatables

在我的ajax数据表中,我初始化了这个:

"ajax": {
    "url": "{{ route('cust_continfo_data_table') }}",
    "dataType": "json",
    "type": "POST",
    "data": {
        _token: "{{ csrf_token() }}",
        cust_id_copy: $("#cust_id_copy").val()
    }
},
"columnDefs": [{
        'targets': 4,
        'createdCell': function (td, cellData, rowData, row, col) {
            $(td).attr('title', 'columns');
        }
    }
],
"columns": [{
        "data": "id"
    }, {
        "data": "receipt_date"
    }, {
        "data": "info_division_name"
    }, {
        "data": "contact_status"
    }, {
        "data": "note"
    }, {
        "data": "created_at"
    }, {
        "data": "updated_at"
    }
],

如您所见,我只分配了静态值colum n in:

$(td).attr('title', 'columns'); 

如何从"data":"note"添加动态值?

1 个答案:

答案 0 :(得分:1)

rowData对象应具有属性note

'createdCell': function (td, cellData, rowData, row, col) {
     $(td).attr('title', rowData.note);
}