【发布时间】:2017-03-14 10:20:06
【问题描述】:
我正在尝试从datatable 的单元格中读取data(),其中有一个按钮,但我遇到了错误。
这是我的Datatable 定义:
$("#example").DataTable({
destroy: true,
"columnDefs": [{
orderable: false,
targets: 0
}],
"columns": [
{
"data": "slno",
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).html('<a href="AddNewTicket.aspx?subjectID=' + oData.subjectID + '&subject_id=' + oData.subject_id + '&serviceID=' + oData.crm_services_id + '&severityID=' + oData.severityID + '&statusID=' + oData.statusID + '&callerID=' + '66355356' + '">' + oData.slno + '</a>');
},
},
{ "data": "status_message" },
{ "data": "crm_services_id" },
{ "data": "subject_id" },
{ "data": "severity_id" },
{"data": "user_id" },
{ "data": "status_id" },
{
"data": "caller_number",
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).html('<button class="btn btn-primary" id= "' + oData.subjectID + '">Call Customer</button>');
},
}
],
select: {
style: 'os',
selector: 'td:first-child'
},
"data": response,
"sDom": '<"top">tip'
});
这是我试图获取数据的地方:
var table = $("#example").DataTable();
$('#example tbody').on('click', 'button', function () {
var subjectID = $(this).attr('id');
var thisData = table.row($(this).parents('tr')).data();
var userID = thisData[7];
sendCallRequest(subjectID, userID);
});
这是我得到的错误:
无法读取 undefined(...) 的属性“_aData”
有什么建议吗?
【问题讨论】:
-
嗨,你解决了吗?
标签: javascript c# jquery datatables