Error on row highlighter page

Error on row highlighter page

Prashant3110Prashant3110 Posts: 6Questions: 2Answers: 0

getting error
var colIdx = myTable.cell(this).index().column;
Uncaught TypeError: myTable.cell is n

https://datatables.net/examples/api/highlight.html

Answers

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    I'm afraid I don't see any errors on the page you linked to. Indeed there isn't even a variable called myTable so I'm not sure how it would show that error at all.

    Can you tell me how to reproduce the error on that page, or give me a link to a page which does show the issue please.

    Allan

  • Prashant3110Prashant3110 Posts: 6Questions: 2Answers: 0
    edited April 2016

    Hi Allan,
    Thanks for your kind response
    I'm using dataTable in my angularJS C# web application

    angular.element(document).ready(function () {
            UserService.GetAlluserlist(function (response) {
                userlist.count = response.count;
                userlist.userlistdata = response.response;
                userlist.backup = userlist.userlistdata;
                setTimeout(setDataTable, 200);
            }, function (response) {
                if (response.error.message != null) {
                    userlist.recordfound = true;
                    userlist.norecordfound = "No Record Forund";
                    userlist.Errorhide = true;
                    userlist.errorMsg = response.error.message;
                }
            });
        });
    

    I'm calling setDataTable() after angular binds data to DOM

        function setDataTable() {
            var myTable = $('#userList').dataTable({
                "sDom":
                        "<'row'<'col-md-4'f><'col-md-4 text-center sm-left'T C><'col-md-4'l>r>" + "t" +
                        "<'row'<'col-md-4 sm-center'i><'col-md-4'><'col-md-4 text-right sm-center'p>>",
                "oLanguage": {
                    "sSearch": ""
                },
                "oTableTools": {
                    "sSwfPath": "vendor/plugins/DataTable/copy_csv_xls_pdf.swf",
                    "aButtons": [
                        {
                            "sExtends": "collection",
                            "sButtonText": 'Download as <span class="caret" />',
                            "aButtons": ["csv", "xls", "pdf"]
                        }]
                    },
    
                "fnInitComplete": function () {
                    $('.dataTables_filter input').attr("placeholder", "Search");
                    $('div.dataTables_filter input').addClass('form-control');
                    $('div.dataTables_length select').addClass('form-control');
                    $('#userList_filter').addClass('pull-left');
                    $('#userList_length').addClass('pull-right');
                }
            });
            
            $('#userList tbody').on('mouseenter', 'td', function ()
            {
                var colIdx = myTable.cell(this).index().column;
                $(table.cells().nodes()).removeClass('highlight');
                $(table.column(colIdx).nodes()).addClass('highlight');
            });
        }
    

    also after adding multiple dataTable(different pages) in my application, save as "csv" and "xls" had stop working hence pdf is working fine

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Thanks - but I'm still not clear on how to reproduce the error on the page you linked to. Can you tell me what actions I need to take on that page or link to a page that shows the issue please.

    Allan

  • Prashant3110Prashant3110 Posts: 6Questions: 2Answers: 0

    Thanks -
    I have resoled the same actually i tried using datatable in angular way that's why i got that error.

    need help on how to use multiple dataTable(on different pages),
    after adding multiple datatables save as "csv" and "xls" is not working

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    need help on how to use multiple dataTable(on different pages),
    after adding multiple datatables save as "csv" and "xls" is not working

    Please link to the page showing the error. I'm afraid I won't be replying in this thread again unless there is a link that I can use to debug the issue as I've already asked for a test case twice above.

    Allan

  • Prashant3110Prashant3110 Posts: 6Questions: 2Answers: 0

    Thanks Allan for replay,

    I can not provide you the link of those pages as it is currently in DEV server,

    There is no any error in console while clicking on CSV or Excel button.
    If i remove dataTables from other page those buttons starts working, and when i put it back it won't works.

    PDF button is working.

    I'm using this code.

        "oTableTools": {
            "sSwfPath": "vendor/plugins/DataTable/copy_csv_xls_pdf.swf",
            "aButtons": [
                {
                    "sExtends": "collection",
                    "sButtonText": 'Download as <span class="caret" />',
                    "aButtons": ["csv", "xls", "pdf"]
                }]
    

    Thanks in advance for any help.

This discussion has been closed.