获取dataTable 行号 以及该行所对应的值

<table class="table table-striped table-bordered dataTable no-footer tableStyles"
id="datatable" style="width: 100%;min-width:320px">
    <thead>
        <tr class="headings">
            <th class="column-title">
                采样时间
            </th>
            <th class="column-title">
                平均值
            </th>
            <th class="column-title">
                极差
            </th>
        </tr>
    </thead>
    <tbody id="qualityTable">
    </tbody>
</table>
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog"
aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">
                        ×
                    </span>
                </button>
                <h4 class="modal-title" id="myModalLabel2">
                    该行详情
                </h4>
            </div>
            <div class="table-responsive">
                <div class="modal-body" id="getCenterValueID">
                </div>
            </div>
        </div>
    </div>
</div>


$('#datatable tbody').on('click', 'tr',function() {
	    $("#myModalLabel2").text("第"+ this.rowIndex +"行数据详情");
 	    var data = dataTables.row(this).data();
	    if (data == null) {
	        $("#spcContentTip").show();
	    } else {
	        var datas = data.slice(3, data.length); //获取从第三个元素开始到最后
	        var code = "";
	        for (var i in datas) {
	            code = code + '<p>' + "数据_" + i + ": " + datas[i] + '</p>'
	        }
	        $("#getCenterValueID").empty().append(code);
	    }
	});



版权声明:本文为zxf1242652895原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。