使用带有数据表的FixedColumns插件时出现问题

时间:2014-09-18 15:13:06

标签: jquery datatables

我正在使用datatables v 1.10和fixedColummns v 3.0.2。以下是我的代码

//创建数据表

var dcInfoDataTable = contentDiv.find('table.dcInfoTable').DataTable( {
                        "aaData": resultMap[dc],
                        "iDisplayLength": 10,
                        "bLengthChange": false,
                        "bAutoWidth": true,
                        "bProcessing": false, 
                        "sScrollX": "100%",
                        "bScrollCollapse": true,
                        "bDeferRender": true,
                        "sScrollXInner":"100%",
                        "aoColumnDefs": aoColumnDefs,
                        "fnCreatedRow": function( nRow, aData, iDataIndex ) {
                            if (aData["comments"] && aData["comments"].indexOf("Error") != -1) {
                                // Do not do anything 
                                $('td:eq(0)', nRow).html(aData["serverName"]+"" +
                                "<a class='btn btn-danger' href='#' data-toggle='tooltip' title='Error in execution'><i class='icon-question'></i></a>");

                            } else {
                                _(aoColumnDefs.length).times(function(n) {
                                    var cnt = n+1;
                                    if ($('td:eq('+cnt+')', nRow).length != 0) {
                                        var className = $('td:eq('+cnt+')', nRow).attr("class");
                                        var arr = className.split("~");
                                        // possible that not all servers has same mount 
                                        if (server_mountedOn[aData["serverName"]+"~"+arr[0]]) {
                                            $('td:eq('+cnt+')', nRow).html(server_mountedOn[aData["serverName"]+"~"+arr[0]][arr[1]]);  
                                        } else {
                                            $('td:eq('+cnt+')', nRow).html(" - ");
                                        }

                                    }
                                });
                            }
                        }
                    });

//调用fixedColumns插件来冻结列

$.fn.DataTable.FixedColumns(dcInfoDataTable);

执行此代码时,我在Chrome控制台中遇到错误。

Uncaught TypeError: Object function ( opts ) {
    return $(this).dataTable( opts ).api();
} has no method '_fnConstruct'

如何解决此问题?

0 个答案:

没有答案