page() not working, mistake @ the docu or I'm too stupid?????

page() not working, mistake @ the docu or I'm too stupid?????

koallalayskoallalays Posts: 6Questions: 2Answers: 0

Hi,

Newest Firefox on Win10
Jquery 3.2.1
Datatables 1.10.16 and also tried 1.10.18

I 've read in the docu that mydatatable.page() will return the current page.
https://datatables.net/reference/api/page()

it seems to me that either the function _api_register isn't working or this part isn't executed coz all these functions aren't working! or there is a mistake @ the docu
Even mytable.draw(); isn't working (!) => so I use mytable.fnDraw();

My Code:

export_filename = 'article_mapping'
    mytable = $("#datatable_box").dataTable({
        data: article_mapping_list,
        dom: 'Blfrtip',
        lengthChange: true,
        pageLength: 50,
        responsive: true,
        deferRender: true,
        ordering: false,
        buttons: [
                {extend: 'csvHtml5', text: datatable_language.buttons.csvHtml5, title: export_filename},
                {extend: 'excelHtml5', text: datatable_language.buttons.excelHtml5, title: export_filename},
                {extend: 'print', autoPrint: false, exportOptions: {columns: ':visible'}, title: export_filename},
            ],
        columns: dt_columns,    
        language: datatable_language,
        createdRow: function( row, data, dataIndex ) {
              $(row).addClass( data.class_name);
        }
    });

var onAjaxSuccess = function(data, form) {
        if (typeof data['data'] != 'undefined') {
            var i;
            for (i in data.data) {
                window[i] = data.data[i]
            }
            try{
                console.log(mytable)
                var page = mytable.page()
                console.log(page)
            } catch(e) {
                console.log(e)
            }
            mytable.fnClearTable();
            prepareMappingList();
            mytable.fnAddData(article_mapping_list);
            mytable.draw();
        }
        form.closest('.modal').modal('hide');
    }

the result:

"$": function n/this.$()

0:

<

table id="datatable_box" class="display article_mapping_datatable dataTable no-footer dtr-inline" role="grid" aria-describedby="datatable_box_info" style="width: 1294px;">

_: function _()

_fnAddColumn: function Lb()

_fnAddData: function Lb()

_fnAddOptionsHtml: function Lb()

_fnAddTr: function Lb()

_fnAdjustColumnSizing: function Lb()

_fnAjaxDataSrc: function Lb()

_fnAjaxParameters: function Lb()

_fnAjaxUpdate: function Lb()

_fnAjaxUpdateDraw: function Lb()

_fnApplyColumnDefs: function Lb()

_fnApplyToChildren: function Lb()

_fnBindAction: function Lb()

_fnBrowserDetect: function Lb()

_fnBuildAjax: function Lb()

_fnBuildHead: function Lb()

_fnCalculateColumnWidths: function Lb()

_fnCalculateEnd: function Lb()

_fnCallbackFire: function Lb()

_fnCallbackReg: function Lb()

_fnCamelToHungarian: function Lb()

_fnClearTable: function Lb()

_fnColumnIndexToVisible: function Lb()

_fnColumnOptions: function Lb()

_fnColumnTypes: function Lb()

_fnConvertToWidth: function Lb()

_fnCreateTr: function Lb()

_fnDataSource: function Lb()

_fnDeleteIndex: function Lb()

_fnDetectHeader: function Lb()

_fnDraw: function Lb()

_fnDrawHead: function Lb()

_fnEscapeRegex: function Lb()

_fnExtend: function Lb()

_fnExternApiFunc: function Lb()

_fnFeatureHtmlFilter: function Lb()

_fnFeatureHtmlInfo: function Lb()

_fnFeatureHtmlLength: function Lb()

_fnFeatureHtmlPaginate: function Lb()

_fnFeatureHtmlProcessing: function Lb()

_fnFeatureHtmlTable: function Lb()

_fnFilter: function Lb()

_fnFilterColumn: function Lb()

_fnFilterComplete: function Lb()

_fnFilterCreateSearch: function Lb()

_fnFilterCustom: function Lb()

_fnFilterData: function Lb()

_fnGetCellData: function Lb()

_fnGetColumns: function Lb()

_fnGetDataMaster: function Lb()

_fnGetMaxLenString: function Lb()

_fnGetObjectDataFn: function Lb()

_fnGetRowElements: function Lb()

_fnGetUniqueThs: function Lb()

_fnGetWidestNode: function Lb()

_fnHungarianMap: function Lb()

_fnInfoMacros: function Lb()

_fnInitComplete: function Lb()

_fnInitialise: function Lb()

_fnInvalidate: function Lb()

_fnLanguageCompat: function Lb()

_fnLengthChange: function Lb()

_fnLengthOverflow: function Lb()

_fnLoadState: function Lb()

_fnLog: function Lb()

_fnMap: function Lb()

_fnNodeToColumnIndex: function Lb()

_fnNodeToDataIndex: function Lb()

_fnPageChange: function Lb()

_fnProcessingDisplay: function Lb()

_fnReDraw: function Lb()

_fnRenderer: function Lb()

_fnRowAttributes: function Lb()

_fnSaveState: function Lb()

_fnScrollDraw: function Lb()

_fnSetCellData: function Lb()

_fnSetObjectDataFn: function Lb()

_fnSettingsFromNode: function Lb()

_fnSort: function Lb()

_fnSortAria: function Lb()

_fnSortAttachListener: function Lb()

_fnSortData: function Lb()

_fnSortFlatten: function Lb()

_fnSortListener: function Lb()

_fnSortingClasses: function Lb()

_fnSplitObjNotation: function Lb()

_fnStringToCss: function Lb()

_fnThrottle: function Lb()

_fnUpdateInfo: function Lb()

_fnVisbleColumns: function Lb()

_fnVisibleToColumnIndex: function Lb()

api: function api()

fnAddData: function fnAddData()

fnAdjustColumnSizing: function fnAdjustColumnSizing()

fnClearTable: function fnClearTable()

fnClose: function fnClose()

fnColReorder: function Lb()

fnDeleteRow: function fnDeleteRow()

fnDestroy: function fnDestroy()

fnDraw: function fnDraw()

fnFilter: function fnFilter()

fnGetData: function fnGetData()

fnGetNodes: function fnGetNodes()

fnGetPosition: function fnGetPosition()

fnIsOpen: function fnIsOpen()

fnOpen: function fnOpen()

fnPageChange: function fnPageChange()

fnSetColumnVis: function fnSetColumnVis()

fnSettings: function fnSettings()

fnSort: function fnSort()

fnSortListener: function fnSortListener()

fnUpdate: function fnUpdate()

fnVersionCheck: function fnVersionCheck()

internal: Object { _fnExternApiFunc: Lb()
, _fnBuildAjax: sa(), _fnAjaxUpdate: lb()
, … }

length: 1

oApi: Object { _fnExternApiFunc: Lb()
, _fnBuildAjax: sa(), _fnAjaxUpdate: lb()
, … }

<prototype>: Object { jquery: "3.2.1", constructor: jQuery()
, length: 0, … }

TypeError: "mytable.page is not a function"
onAjaxSuccesshttp://127.0.0.1:8000/henkel_frontend/manage/article_mapping:407:15ajax_form_completehttp://127.0.0.1:8000/henkel_frontend/static/js/components/form_dialogs.js?v=109:288:6successhttp://127.0.0.1:8000/henkel_frontend/static/js/components/form_dialogs.js?v=109:369:45firehttp://127.0.0.1:8000/henkel_frontend/static/js/libs/jquery-3.2.1.min.js?v=109:2:31072fireWithhttp://127.0.0.1:8000/henkel_frontend/static/js/libs/jquery-3.2.1.min.js?v=109:3:172donehttp://127.0.0.1:8000/henkel_frontend/static/js/libs/jquery-3.2.1.min.js?v=109:4:19343callbackhttp://127.0.0.1:8000/henkel_frontend/static/js/libs/jquery-3.2.1.min.js?v=109:4:26444 a

Answers

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin

    Change:

    mytable = $("#datatable_box").dataTable({

    To be:

     mytable = $("#datatable_box").DataTable({
    

    See this FAQ.

    Allan

  • koallalayskoallalays Posts: 6Questions: 2Answers: 0

    Thanks, yes that works, but its a bit confusing. I didn't even know that JavaScript is case-sensitive .... never tried it out ...

    I found out that
    mytable.api(true).page(3) doesn't work with 1.16 but with 1.18 it works. Don't remember if i had draw('page') afterwards ... but it was a bit strange and took me hours to get 2 lines of code working :(

    Your solution works with 1.16 too so I don't need to update all my projects ...

This discussion has been closed.