Error in resolving to datatables api

Error in resolving to datatables api

migandhimigandhi Posts: 3Questions: 2Answers: 0

Error messages shown:

Description of problem:
Hi,

Datatable.CoreMethods : Otable.page is not found .Datatable.PageMethods dont resolve , hence the function is not found and throws exception.

What could be the issue, Pagination works. I use mData aoColumns.

Thanks,
Regards.

Answers

  • kthorngrenkthorngren Posts: 21,174Questions: 26Answers: 4,923

    You are using Datatables 1.9 command/option notation style. See the Legacy interface notice message above your first post for more info.

    Are you using Datatables 1.9 or 1.10? 1.9 doest not have a page() API.

    Please post your client side code. Or better post a link to your page or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • migandhimigandhi Posts: 3Questions: 2Answers: 0

    Client Side Code in cshtml containing javascripts:

    var pageno = GetTextBoxPage();
    var Otable = $("#tblVideoFeeds").dataTable({
    ajax: {

                url: '@Url.ActionLink("Index","VideoFeed")',
                type: "POST",
                dataType: 'json',
                dataSrc: function (json) {
                    return json.data;
                },
                data: function (data, settings) {
                    data.SearchModel = serializeFormValues('searchVideoFeedForm');
                }
    
            },
            "bServerSide": true,
            "bProcessing": true,
            "searching": false,
            "ordering": false,
    
    
                     aoColumns: [
                         {
                            mData: 'videoTitle',
                            mRender: function (data, type, Video) {
                            var url = "Video/DisplayVideo?id=" + Video.videoId;
                            return "<a href='javascript:void(0)' onclick=showInPopup('" + url + "','Video_View')>" + Video.videoTitle + "</a>";
                             }
                         },
                         { mData: 'userName' },
                         { mData: 'category' },
                         { mData: 'language' },
                         { mData: 'videoFileName' },
                        {
                        mData: 'createdAt', "mRender": function (data, type, full) {
                        var date = new Date(data)
                        return (formatDate(date));
                        }},
                        {
                        mData: "reviewStatus",
                            mRender: function (data, type, row) {
                                return "<div>" + (row.reviewStatus == 1 ? "Pending" : (row.reviewStatus == 2 ? "Accepted" : "Rejected" )) +"</div>"
                            }
                        },
                        { mData: 'hashTags' },
                         { mData: 'rating',
                            mRender: function (data, type, Video) {
                             return "<div data-rating="+Video.rating+" class='star-rating'></div>"
                            }
                        },
                        { mData: 'totalViews' },
                        { mData: 'totalLikes' },
                     { mData: 'totalComments' },
                     { mData: 'totalShares' },
                     { mData: 'userType' }]
        });
    
    
    
        function GetTextBoxPage() {
            return $("#PageNumber").val() == '0' ? 0 : parseInt($("#PageNumber").val());
        }
    
        jQuery("#btnSearch").click(function () {
    
            pageno = GetTextBoxPage();
            console.log('reload----: ' + pageno);
            Otable.page(pageno - 1).draw(false);
        });
    
        //on textbox enter - call search
        jQuery(document).on("keypress", ".searchText", function (e) {
            if (e.which == 13) {
                Otable.ajax.reload();
                return false;
            }
        });
    
  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,174Questions: 26Answers: 4,923

    You have var Otable = $("#tblVideoFeeds").dataTable({. To access the API you need to use var Otable = $("#tblVideoFeeds").DataTable({. Notice the upper case D in `DataTable. See the PI docs for more details.

    Kevin

This discussion has been closed.