var table = jQuery("#list_info")
var tdObject = $("#" + rowid + ">td:nth-child('" + (iCol + 1) + "')")
tdObject.html('<input type="checkbox" name="listenClass"/>')
}
写一个最简单的例子做参考吧 import java.awt.BorderLayoutimport java.awt.Container
import java.awt.Dimensionimport javax.swing.JFrame
import javax.swing.JTable
import javax.swing.table.DefaultTableModelpublic class JTableTest extends JFrame {
private JTable table
private DefaultTableModel model
private Object[] header={"1","2","3"}
private Object[][] data={{"sdf",new Integer(1),new Boolean(false)},{"abc",new Integer(2),new Boolean(true)}}
public JTableTest()
{
initComponent()
this.setMinimumSize(new Dimension(300,300))
this.setLocationRelativeTo(null)
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
}
private void initComponent()
{
Container content=this.getContentPane()
model=new DefaultTableModel(data,header){
public Class<?>getColumnClass(int columnIndex) {
return getValueAt(0, columnIndex).getClass()
}
}
table=new JTable(model)
content.add(table.getTableHeader(),BorderLayout.NORTH)
content.add(table)
}
public static void main(String[] args) {
new JTableTest().setVisible(true)}
}
bootstrap框架中让table中显示checkbox的具体的方法步骤如下:
<script>
$(function () {
$("#checkAll").click(function () {
$("input[name='imgVo']:checkbox").prop("checked", this.checked)
})
})
</script>
<table class="table table-hover" style="width: 45%">
<thead>
<tr>
<th><input type="checkbox" id="checkAll"/></th>
<th>#</th>
<th>文件名</th>
<th>修改时间</th>
<th> *** 作</th>
</tr>
</thead>
<tbody>
<c:forEach var="imgVo" items="${page.list}" varStatus="st">
<tr>
<td><input type="checkbox" name="imgVo" value="${imgVo.fileName}"/></td>
<td>${st.count}</td>
<td>${imgVo.fileName}</td>
<td><fmt:formatDate value="${imgVo.modifyTime}" pattern="yyyy-MM-dd hh:mm:ss"/></td>
<td><a href="${ctx}/uploadimg/show/${imgVo.fileName}" target="_blank">查看</a>
<a href="${ctx}/uploadimg/downloads/${imgVo.fileName}">下载</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)