小编Hom*_*mam的帖子

如何在没有表重绘的情况下更新数据表中的行?

我有一个从javascript数组填充的dataTables v1.9.4,我有复选框列,如果它是:checked整个行应该每5秒更新一次,问题是我有一个大的fnRowCallback函数,在行更新后没有执行所以我的所有行结构崩溃.这是我的更新代码:

function updateRow(){
    newRowData = $.data(document.body, 'updatedData');
    var newRow = [];
    newRow.push(1, 1);
    for (var title in newRowData[0]){
        newRow.push(newRowData[0][title]);
    }
    oTable.fnUpdate( newRow, updateIndex, false, true);
};  
Run Code Online (Sandbox Code Playgroud)

这个我的fnRowCallback:

"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
                //make 3state button and indicator for relay mask & status
                $('td.relay', nRow).each(function(){
                    relayStatus = $(this).text();
                    $(this).html('<div class="hidden-value">' + relayStatus + '</div><div></div>');
                    if(relayStatus == 1){
                        $(this).children('div:last').addClass('relmas1');
                    }
                    if(relayStatus == 0){
                        $(this).children('div:last').addClass('relmas0');
                    }
                    if(relayStatus == -1){
                        $(this).children('div:last').addClass('relmas-1');
                    }
                });
                //makes update …
Run Code Online (Sandbox Code Playgroud)

javascript arrays jquery jquery-datatables

8
推荐指数
1
解决办法
2万
查看次数

如何将类添加到jquery.datatables列?

我为jquery.datatables制作了一个大表,这对我很有用.
但是我需要为每个td元素设置一个相对于其列的类名.
例如,我想要一个列(包括th和所有td)都有一个class="volume".
有这个问题:
我使用此代码初始化类但它不起作用.

"aoColumnsDefs": [
    { "sClass": "volume", "aTargets": [2] }
]
Run Code Online (Sandbox Code Playgroud)

编辑: 我的表被创建并动态刷新.它是由一个js阵列组成,我宁愿不接触它,即.只是添加类名称
编辑:
我使用此代码来itialize我的表:

$('#dataTable').dataTable({
    "aaData": dataCnt,
    "aoColumnsDefs": [
        { "sClass": "volume", "aTargets": [2] }
    ],
    "aoColumns": columnsHd,
    "bStateSave": true,//saving status in coockie
    "iCookieDuration": 10,//coockie life duration in seconds
    "sScrollX": "100%",
    "sScrollY": (winHei-200),
    "sDom": '<"H"RCfrl>t<p"F"i>',
    "oColVis": {
        "buttonText": "&nbsp;",
        "bRestore": true,
        "sAlign": "left"
    },
    "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
});
Run Code Online (Sandbox Code Playgroud)

我希望它有帮助*EIDT:*
columnsHd是一个从我的json标题动态创建的数组,现在正是:

[
{ "sTitle": "macaddr" },
{ …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery datatables

7
推荐指数
1
解决办法
2万
查看次数

npm插件"onchange"无法识别scss文件的更改

我是npm newbee并尝试使用纯粹的npm进行非常简单的构建过程(没有grunt,gulp等).我的所有包json脚本都可以正常工作,负责监视SCSS文件并在文件更改时运行编译器.
这是我的Package.json文件,应该是自我解释:

    {
      "name": "test-site.com",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "scss": "node-sass --indent-type tab --indent-width 1 --output-style expanded -o dist/css src/scss",
        "autoprefixer": "postcss -u autoprefixer -r dist/css/app.css",
        "build:css": "npm run scss && npm run autoprefixer",
        "serve": "browser-sync start --server --files 'dist/css/*.css, **/*.html, !node_modules/**/*.html'",
        "reload": "browser-sync reload",
        "watch:css": "onchange 'src/scss/*.scss' -- npm run build:scss",
        "build:all": "npm run build:css",
        "watch:all": "npm-run-all -p serve watch:css",
        "postinstall": "npm run build:all && npm run watch:all"
      },
      "author": "Homam",
      "license": "ISC",
      "devDependencies": …
Run Code Online (Sandbox Code Playgroud)

onchange build-tools node.js npm

2
推荐指数
2
解决办法
1732
查看次数