Uncaught TypeError:无法读取未定义的属性'req_tanggal'

问题描述 投票:0回答:1

我在从数据表获取记录以输入文本时遇到问题,当我在错误日志中单击数据表中的记录时,显示此消息“ datatable.js:2274 Uncaught TypeError:无法读取未定义的属性'req_tanggal'”

这是我的代码:

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>
javascript jquery datatable
1个回答
2
投票

您正在尝试使用jQuery #id Selector $('#req_tanggal'),但没有HTML元素具有相应的id

如下更改th元素<th>req_tanggal</th>,它应该起作用。

<th id="req_tanggal"></th>
© www.soinside.com 2019 - 2024. All rights reserved.