jquery ui datatables用不用添加行和列

jquery ui datatables用不用添加行和列,第1张

指定CSS为表:table.display {

margin: 0 auto

width: 100%

clear: both

border-collapse: collapse

table-layout: fixed // add this

word-wrap:break-word // add this

}

HTML:<table id="companiesTable" class="display">

<thead>

<tr>

<th>Company name</th>

<th>Address</th>

<th>Town</th>

</tr>

</thead>

<tbody>

你新添加的两行和之前那一行的结构是不一样的,你调用的DataTable 肯定对原有的那一行的table做出调整,才会固定左4列 而你动态添加的那两行并没有调用到 datatable 函数 肯定不能固定

直接上代码吧:

DataSet ds=bor.borrow_book(bookISBN.Text,"tbname")

DataTable tbl=ds.Tables["tbname"]

tbl.Columns.Add("borrow_time",typeof(string))

tbl.Columns.Add("bor_number",typeof(string))

DataRow dr=tbl.NewRow()

dr["borrow_time"]="2012-12-23"

dr["bor_number"]="1"

tbl.Rows.Add(dr)

dataGridView1.DataSource=tbl

你的错误在于,你的ds中根本就没有名字为tbl的table,况且你已经把table取出来了就没必要再去 *** 作dataset了。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11846931.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存