javascript - 未捕获的类型错误:无法读取未定义的属性“req_tanggal”
问题描述
从数据表获取记录以输入文本时出现问题,当我在错误日志中单击数据表中的记录时显示此消息“datatable.js:2274 Uncaught TypeError: Cannot read property 'req_tanggal' of undefined”
这是我的代码:
var tpropen;
var tpropen1;
$(document).ready( function ()
{
tpropen = $('#tpropen').DataTable({
"columnDefs":[{ "orderable": false,"className": "select-checkbox","targets": [0],"checkboxes": {"selectRow": true}}],
"select": {"style": "multi"},
"order": [[0, "asc"]],
"sAjaxSource": "/HPR_validate",
"scrollX": "200px",
"sAjaxDataProp": "",
"aoColumns":
[
{ "mData": "id_header_pr", "defaultContent": ""},
{ "mData": "req_tanggal", "defaultContent": ""},
{ "mData": "kode_pr", "defaultContent": ""},
{ "mData": "jenis_pr", "defaultContent": ""},
{ "mData": "status", "defaultContent": ""}
]
});
tpropen.on('click', function(e)
{
var form = this;
var rows_selected = tpropen.column(0).checkboxes.selected();
$('#id_header_pr').val(rows_selected.join(","));
tpropen1 = $('#tpropen').DataTable().row('.selected').data();
$('#req_tanggal').val(tpropen1 ['req_tanggal']); // $('#req_tanggal') this is input text////
});
//setInterval (tabelhpropen.ajax.reload, 1000);
});
<div class="tab-pane active" id="tab_1x">
<div >
<div class="panel panel-default">
<table class="table table-striped table-bordered table-hover" id="tpropen" role="grid" style="width: 100%;" width="100%">
<thead>
<tr>
<th>id_header_pr</th>
<th>req_tanggal</th>
<th>kode_pr</th>
<th>jenis_pr</th>
<th>status</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
解决方案
You're trying to use the jQuery #id Selector $('#req_tanggal')
but no HTML element has a corresponding id
.
Change the th
element <th>req_tanggal</th>
as follows and it should work.
<th id="req_tanggal"></th>
推荐阅读
- excel - VBA:Else Statement - 什么是正确的代码?
- javascript - 如何为特定的 HTML 表格列应用 focus()?
- eclipse - Eclipse 安装问题 -org.eclipse.oomph.setup.p2 code=0 java.security.NoSuchAlgorithmException: MD5 MessageDigest 不可用
- sas - 有什么巧妙的方法来重组数据集(可能有滞后和输出)?
- r - 在 R 中的目录内创建文件夹并使用文件名保存结果以保存绘图
- java - 使用 Java 创建 Node.js 加密密钥
- javascript - 在javascript中有一些聪明的方法来检查对象中的对象是否存在?
- java - Android ComputableFuture 不适用于 Firestore
- angular - 只有在 app-routing.module.ts 中路由时,组件才使用主布局
- javascript - 通过按下按钮计算点击次数