I can't use dataTables API

I can't use dataTables API

michaelhnmichaelhn Posts: 2Questions: 2Answers: 0
edited July 2014 in Free community support

I already create a table for my web-app

$(document).ready(function() {
                $('#request-table').dataTable({
                    "scrollX": true,
                    "sAjaxSource": "/somuploader/request/listRequestJSON",
                    "columns": [
                        {
                            data: null,
                            className: "center",
                            defaultContent: '<input type="button" class="btn-warning editor_edit" onclick="" value="Lihat" />  \n\
                                 <input type="button" class="btn-danger editor_remove" onclick="deleteIfPossible()" value="Delete"/>'
                        },
                        {"data": "reqNo"},
                        {"data": "reqDate"},
                        {"data": "reqBatchNo"},
                        {"data": "reqClId"},
                        {"data": "reqBatchDescription", "width": "30px"},
                        {"data": "reqStatus"}
                    ],
                    "columnDefs": [{
                            "targets": -1,
                            "data": null,
                            "defaultContent": "<button>Click!</button>"
                        }]
                });
            });

next is I want to create a delete button, the function for delete is done, but I need the value from the 2nd column of the table
I think the solution will be similar with these

aPos=oTableLocal.fnGetPosition(aTrs[i]);
aData=oTableLocal.fnGetData(aTrs[i]);

but this is my real question, every time I type "oTable." my netbeans didnt show me any of methods above,
not any of fnMethod, I already able to create my table using .datatable() , so I think I already able to use datatables API, but then
why I cant use any other method?

Answers

  • bdunsmuirbdunsmuir Posts: 17Questions: 4Answers: 0

    You don't have a datatable object called oTable, that's why you can't access it.

    you need something like:

     oTable = $('#request-table').dataTable({
    

    Then you can do:

    aPos=oTable.fnGetPosition(aTrs[i]);
    

    You can replace oTable with any name you like.

This discussion has been closed.