【问题标题】:How to add ajax data in attribute in td element如何在 td 元素的属性中添加 ajax 数据
【发布时间】:2018-01-23 12:59:02
【问题描述】:

在我的 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"
    }
],

如您所见,我只分配了静态值,即column in:

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

如何添加来自"data":"note" 的动态值?

【问题讨论】:

    标签: javascript jquery ajax datatables


    【解决方案1】:

    rowData 对象应具有属性note

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-21
      • 1970-01-01
      • 1970-01-01
      • 2017-05-28
      • 1970-01-01
      • 2015-01-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多