weixin_33711647 2012-05-26 22:33 采纳率: 0%
浏览 42

使用AJAX删除表格行

I'm using AJAX to remove specific rows from jQuery Datatable. These rows have value 0 in the 10th column (if we start counting from 0). Below you can see my code. For some reason, it does not remove any row. I checked the value of aData[10] => it is definetely equal to 0 in some rows.

     $(document).ready(function(){
          $('#newspaper-b').dataTable({
          "sPaginationType":"full_numbers",
          "aaSorting":[[4, "asc"]],
          "aoColumns": [null,null,null,null,null,null,null,null,null,null,
                        {"bSearchable": true, "bVisible": false},null,null],
          "bJQueryUI":true,
          'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                if(aData[10]=="0"){
                    $(nRow).remove();
                }
                return nRow;
            }
          });

UPDATE

When I do this:

'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                      var r=confirm(aData[10]);
                  if (parseInt(aData[10], 10) === 0) {
                        $(nRow).remove();
                    }
                    return nRow;
                }

...then I can see that one of rows has 0. But when I do this:

'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                  if (parseInt(aData[10], 10) === 0) {
var r=confirm(aData[10]);
                        $(nRow).remove();
                    }
                    return nRow;
            }

...then alert JS message (i.e. var r=confirm(aData[10])) does not appear, which means that IF statement returns false. BUT WHY???

![enter image description here][1]

  • 写回答

1条回答 默认 最新

  • 北城已荒凉 2012-05-26 22:36
    关注

    This may possibly be a typing issue. Try converting the column value to an integer like this:

    if (parseInt(aData[10], 10) === 0) {
        $(nRow).remove();
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型