使用 BootstrapTable 添加行时使用 CellStyle
Using CellStyle when adding rows with BootstrapTable
我有一个 Bootstrap-Table,其中有一个用于添加新数据行的按钮。我想为插入的每个新行的特定列(text2)的单元格着色。我正在使用内置方法 cellStyle()
,如下所示:http://jsfiddle.net/wenyi/e3nk137y/9/,但函数方法似乎从未被调用过。
Bootstrap-Table 的文档:
http://bootstrap-table.wenzhixin.net.cn/documentation/
Table 带有 cellStyle 参数的声明:
<table id="table" data-pagination="true" data-cell-style="cellStyle" class="table table-striped"></table>
添加样式的函数:
function cellStyle(value, row, index, field) {
if (index === 0 && field == 'text2') {
return {classes: 'warning'};
}
else {
return {};
}
}
我的完整代码:
类似的东西? http://jsfiddle.net/fp61qL0k/
文档说您应该将函数添加到 table 列 header,而不是 table 本身。从这里开始,它只是在操纵函数。
{
field: 'text2',
title: 'TEXT 2',
cellStyle: cellStyle,
}
我有一个 Bootstrap-Table,其中有一个用于添加新数据行的按钮。我想为插入的每个新行的特定列(text2)的单元格着色。我正在使用内置方法 cellStyle()
,如下所示:http://jsfiddle.net/wenyi/e3nk137y/9/,但函数方法似乎从未被调用过。
Bootstrap-Table 的文档: http://bootstrap-table.wenzhixin.net.cn/documentation/
Table 带有 cellStyle 参数的声明:
<table id="table" data-pagination="true" data-cell-style="cellStyle" class="table table-striped"></table>
添加样式的函数:
function cellStyle(value, row, index, field) {
if (index === 0 && field == 'text2') {
return {classes: 'warning'};
}
else {
return {};
}
}
我的完整代码:
类似的东西? http://jsfiddle.net/fp61qL0k/
文档说您应该将函数添加到 table 列 header,而不是 table 本身。从这里开始,它只是在操纵函数。
{
field: 'text2',
title: 'TEXT 2',
cellStyle: cellStyle,
}