html代码如下:
<table
id="table"
data-toggle="table"
th:attr="data-url=@{/view/vdata(view=${table_name})}"
data-pagination="true"
data-toolbar="#toolbar"
data-side-pagination="server"
data-search="false"
data-data-field="list"
data-id-field="id"
data-show-footer="false"
data-page-size="10"
data-page-number="1"
data-show-refresh="true"
data-show-toggle="false"
data-height="500"
>
<thead>
<tr>
<th th:each="st,data:${st2}" th:attr="data-field=${st.lieming}" th:text="${st.asname}" >断面名称</th>
</tr>
</thead>
</table>
js如下:
$("#table").on("click-row.bs.table",function(e,row,ele){
$(".danger").removeClass("danger");
$(ele).addClass("danger");
});
/*获取选中行对象*/
function getContent(){
var index = $("#table").find("tr.danger").data("index");
var list = $("#table").bootstrapTable('getData')[index];
if(list==null){
alert("请选中一行");
return false;
}else{
$("#modal3").attr({"data-target":"#myModal3"});
}
$("#dataForm3 input[type='text']").each(function(){
$(this).val(list[$(this).attr("name")] ? list[$(this).attr("name")] : "");
});
}