jQuery table.row 不是函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25617251/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:08:28  来源:igfitidea点击:

table.row is not a function

jquerydatatablesjquery-datatables

提问by MaVRoSCy

I am trying to implement row details in my datatablesjust like this example.

我想实现我行详细信息的数据表就是这样的例子

When I click on the show more image of my table, I get an error in my firebug console saying:

当我单击“显示更多我的表的图像”时,我的萤火虫控制台中出现错误消息:

TypeError: oTable.row is not a function
var row = oTable.row(tr);

Here is also a fiddleof my code that generates this error.

这也是我生成此错误的代码的小提琴

As i understand it, the row()function of my datatables is not found. But i don't get it... I use the latest datatables version with jquery version 1.11.1 (and not 1.11.0 as shown in fiddle) which is what is used in the example also(on datatables website).

据我了解,row()我的数据表的功能没有找到。但我不明白......我使用最新的数据表版本和 jquery 版本 1.11.1(而不是 1.11.0,如小提琴所示),这也是示例中使用的(在数据表网站上)。

I am stuck... Anyone has any idea why I get this error?

我被卡住了......有人知道我为什么会收到这个错误吗?

Thanks a lot

非常感谢

回答by Karlen Kishmiryan

I don't know what is the difference between dataTableand DataTablefunctions, but your code worked when I initialized the data table using the second function.

我不知道dataTableDataTable函数之间有什么区别,但是当我使用第二个函数初始化数据表时,您的代码有效。

 oTable = $('#tblCasesMain').DataTable({ ...

Here is the fiddle, which only gives an error on formatfunction which is not defined.

这是fiddle,它只会在format未定义的函数上给出错误。

Note: I have changed that function name as per this example.

注意:我已按照此示例更改了该函数名称。

Update:I have done a bit of research and got the answer. Take a look at the Upgrade noteherewhich says the following:

更新:我做了一些研究并得到了答案。看看这里升级说明其中说明如下:

If you are upgrading from DataTables 1.9 or earlier, you might notice that a capital D is used to initialise the DataTable here. $().DataTable() returns a DataTables API instance, while $().dataTable() will also initialise a DataTable, but returns a jQuery object.

如果您是从 DataTables 1.9 或更早版本升级,您可能会注意到这里使用大写 D 来初始化 DataTable。$().DataTable() 返回一个DataTables API 实例,而$().dataTable() 也会初始化一个 DataTable,但返回一个jQuery 对象。

回答by U. Kadner

There is not need to use .DataTable()instead of dataTable()

不需要使用.DataTable()代替dataTable()

Simply append .api(). It will return the object that defines the required row()method.

简单地附加.api(). 它将返回定义所需row()方法的对象。

e.g.: var row = oTable.api().row(tr);

例如: var row = oTable.api().row(tr);

回答by user3209031

This is because you haven't mention Function

这是因为你没有提到 Function

Check Update Working Link http://jsfiddle.net/2gLqgL7m/7/

检查更新工作链接http://jsfiddle.net/2gLqgL7m/7/

回答by Praveen Mitta

If the above answers don't work in your case, try below alternate.

如果上述答案在您的情况下不起作用,请尝试以下替代方法。

var row = $('#tblSample').DataTable().row(tr);

Instead of

代替

var oTable =  $('#tblSample').dataTable( {
    //Code
 });
var row = oTable.row(tr);

回答by Mr. HK

Update dataTable()wuth DataTable()No need to use .dataTable()

更新dataTable()wuthDataTable()无需使用.dataTable()

Use .DataTable()

.DataTable()

Example :

例子 :

oTable = jQuery('#tblCasesMain').DataTable({ ...