数据表的Aocol列不起作用 [英] Aocolumns of datatables are not working

查看:57
本文介绍了数据表的Aocol列不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Please find attached the application picture, where the column ORDER ID is not showing, and instead of that, is showing the PLUS sign. So all the columns should shift for one to the right.

ajax And all the time when I run the application it shows me this error message:

DataTables warning (table id = 'companies'): Added data (size 3) does not match known number of columns (4)










var oTable;
    $('#companies tbody td img').live('click', function () {
    var nTr = this.parentNode.parentNode;
    if (this.src.match('details_close')) {
    /* This row is already open - close it */
    this.src = "/Content/images/details_open.png";
    oTable.fnClose(nTr);
    }
    else {
    /* Open this row */
    this.src = "/Content/images/details_close.png";
    var orderid = $(this).attr("rel");
    $.get("Me?OrderID=" + orderid, function (detalet) {
    oTable.fnOpen(nTr, detalet, 'details');
    });
    }
    });

    /* Initialize table and make first column non-sortable*/
    oTable = $('#companies').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": 'AjaxHandler',
    "bJQueryUI": true,
    "aoColumns":
     [
    { "bSortable": false, 
    "bSearchable": false,
    "fnRender": function (oObj)
     {
    return '<img src="/Content/images/details_open.png" alt="expand/collapse" rel="' + oObj.aData[0] + '" />';
    }
    },
    null,
    null,
    null
    ]
    });







< br $>







<table id="companies" class="display">
        <thead>
            <tr>
                <th> </th>
                <th>Order  ID</th>


                <th>Customer ID</th>
              
                <th>Ship Address</th>
        
            </tr>
        </thead>
        <tbody></tbody>
    </table>
 Run code snippet
















the first column of the table should be the image img , then is order id , then is customer id , then is ship address .thats it.





我尝试了什么:



i刚刚解释了上面的问题



What I have tried:

i just explained the problem above

推荐答案

('#companies tbody td img')。live('click',function(){
var nTr = this.parentNode.parentNode;
if(this.src.match('details_close')){
/ *此行已经打开 - 关闭它* /
this.src =/Content/images/details_open.png;
oTable.fnClose(nTr);
}
else {
/ *打开这一行* /
this.src =/Content/images/details_close.png ;
var orderid =
('#companies tbody td img').live('click', function () { var nTr = this.parentNode.parentNode; if (this.src.match('details_close')) { /* This row is already open - close it */ this.src = "/Content/images/details_open.png"; oTable.fnClose(nTr); } else { /* Open this row */ this.src = "/Content/images/details_close.png"; var orderid =


(this).attr(rel);
(this).attr("rel");


.get(Me?OrderID = + orderid,function(detalet){
oTable.fnOpen(nTr,detalet,'detail s');
});
}
});

/ *初始化表并使第一列不可排序* /
oTable =
.get("Me?OrderID=" + orderid, function (detalet) { oTable.fnOpen(nTr, detalet, 'details'); }); } }); /* Initialize table and make first column non-sortable*/ oTable =


这篇关于数据表的Aocol列不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆