Javascript 设置引导表中新行的背景色
我正在使用Javascript 设置引导表中新行的背景色,javascript,jquery,css,twitter-bootstrap,bootstrap-table,Javascript,Jquery,Css,Twitter Bootstrap,Bootstrap Table,我正在使用Bootstrap表和Editable插件。我有一个按钮向表中添加新行。我希望Notes列中新行的单元格背景颜色为蓝色 从: 唯一与这些参数一致并添加新行的是index=0,因此我将所有其他参数默认为Null。似乎我的函数甚至没有被调用。我是JavaSript新手,所以我可能遗漏了一些东西 试试这个 更改: 添加新行时,我添加了paintBlue=true 已将cellStyle更新为此 function cellStyle(value=Null, row=Null, index=
Bootstrap表
和Editable
插件。我有一个按钮向表中添加新行。我希望Notes
列中新行的单元格背景颜色为蓝色
从:
唯一与这些参数一致并添加新行的是index=0,因此我将所有其他参数默认为Null
。似乎我的函数甚至没有被调用。我是JavaSript
新手,所以我可能遗漏了一些东西
试试这个
更改:
添加新行时,我添加了paintBlue=true
已将cellStyle
更新为此
function cellStyle(value=Null, row=Null, index=0, field=Null) {
if(row.paintBlue) {
return {css: {"background-color": "blue"}}
}
return {};
}
定义列时传递cellStyle
函数,而不是传递html数据单元格样式
属性
...
{
field: 'Notes',
sortable: 'true',
cellStyle: cellStyle,
title: 'Notes',
editable: {
type: 'textarea'
}
...
function cellStyle(value=Null, row=Null, index=0, field=Null) {
if(row.paintBlue) {
return {css: {"background-color": "blue"}}
}
return {};
}
...
{
field: 'Notes',
sortable: 'true',
cellStyle: cellStyle,
title: 'Notes',
editable: {
type: 'textarea'
}
...