简体   繁体   中英

jQuery DataTables fnGetPosition is not a function?

Here's what my code does (except the variable is in a more complex system with arrays):

var dataTable = $([some-DOM-table]).dataTable().columnFilter();
dataTable.fnGetPosition([some-DOM-tr-object]);

I get error 'fnGetPosition is not a function'.

I have included 'jquery.dataTables.min.js' and 'jquery.dataTables.columnFilter.js'. I'm a still missing a file or what is wrong with my code?

I think you missed “.dataTable()” in $([some-DOM-table]);

Below code will help you. It is working as required.

<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.min.js" language="javascript" type="text/javascript">  </script>
<script src="jquery.dataTables.min.js" language="javascript">
</script>
<script language="javascript">
    $(document).ready(function () {
        $('#example tbody tr').click(function () {
            var aPos = oTable.fnGetPosition(this);
            alert(aPos);
        });
        var oTable = $('#example').dataTable().columnFilter();
    });
 </script>
</head>
<body>
<form id="form1" runat="server">
<table id="example">
<thead>
  <tr><th>Header</th></tr>
</thead>
<tbody>
  <tr><td>data1</td></tr>
  <tr><td>data2</td></tr>
  <tr><td>data3</td></tr>
</tbody>
</table>
</form>
</body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM