Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 设置引导表中新行的背景色_Javascript_Jquery_Css_Twitter Bootstrap_Bootstrap Table - Fatal编程技术网

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'
}
...