Need help in identfying the iDisplayLength default value while migrating from 1.9.2. to 1.13.7

Need help in identfying the iDisplayLength default value while migrating from 1.9.2. to 1.13.7

MagizhMagizh Posts: 6Questions: 1Answers: 0

I am trying to migrate my project to the latest jQuery datatable version.In the old version(1.9.2) I noticed that it is taking the default value for iDisplayLength as 234.I tried searching the whole code and I couldnt understand where the value is set.In 1.13.7 version it is taking the default value as 10,I understand this is the default value defined in the dataTables.js file.
Can anyone help me identifying where the value '234' is set in the older version please.
Thanks in advance.

Answers

  • allanallan Posts: 63,439Questions: 1Answers: 10,459 Site admin

    Do you mean that you think DataTables' default was 234? It has been 10 since its very first release, and I doubt it will ever change. It certainly wasn't 234.

    If you link to your page where it is 234 then I'll probably be able to identify where that is being done.

    If you want to set the page length with the latest DataTables, use pageLength.

    Allan

  • MagizhMagizh Posts: 6Questions: 1Answers: 0

    Thanks for your response Allan.I dont see it explicitly set in my code as well.I am new to jQuery.Probably I am overlooking something which is obvious.The length is set to display based on the below code snippet:
    $.get('List.action',
    {
    mode: 'allcamerasforrcc',
    rccId: selectedRCC,
    dataTable: true,
    sid: Math.random(),
    iDisplayStart: settings._iDisplayStart,
    iDisplayLength: settings._iDisplayLength,
    sSearch: searchString,
    sSortDir_0: settings.aaSorting[0][1],
    road: lastFilteredOn,
    statusOnly: true
    },

    The value in settings._iDisplayLength is 234.Not sure where it is picking from.We are also using datatables.scroller.js in our project.Does it have any dependancy on the scroller?

  • kthorngrenkthorngren Posts: 21,292Questions: 26Answers: 4,944

    I would look through your Javascript code to see where settings._iDisplayLength is set. Datatables wouldn't set that or any of the other above variables.

    Kevin

  • MagizhMagizh Posts: 6Questions: 1Answers: 0

    what is the best approach to share the code as I dont want to post the entire file here.
    Thanks!!

  • MagizhMagizh Posts: 6Questions: 1Answers: 0

    I hope you are looking for this.It is fetched from fnSettings() and set it in settings variable.I dont have much idea on how fnSettings works.

    function refreshDataTable(){

    if (camListDataTable == undefined || cameraListForTable == undefined) {
        return;
    }
    
    var settings = camListDataTable.fnSettings();
    var searchString = $("input", "#cameraListTable_filter").val();
    
    $.get('List.action',
        {
            mode: 'allcamerasforrcc',
            rccId: selectedRCC,
            dataTable: true,
            sid: Math.random(),
            iDisplayStart: settings._iDisplayStart,
            iDisplayLength: settings._iDisplayLength,
            sSearch: searchString,
            sSortDir_0: settings.aaSorting[0][1],
            road: lastFilteredOn,
            statusOnly: true
        },
    
  • kthorngrenkthorngren Posts: 21,292Questions: 26Answers: 4,944

    Possibly Github or other source code repository. It may not execute but you can place the code in one of these resources for test cases:
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • allanallan Posts: 63,439Questions: 1Answers: 10,459 Site admin

    Are you using Scroller? That will increase the default page length.

    Like Kevin says, we need a test case so we have all the information available.

    Allan

  • MagizhMagizh Posts: 6Questions: 1Answers: 0

    Hi Allan,

    I have placed my function in the below path :

    https://live.datatables.net/mafucexa/1/

    Before upgrade we were using jquery.dataTables-1.9.2.min.js and dataTables.scroller.min.js version 1.1.0.

    When using the old version,I noticed that the below fn from scroller is called and the iDisplayLength value is set to 234 in aoData.

        fnMeasure: function(a) {
            this.s.autoHeight && this._fnCalcRowHeight();
            this.s.viewportHeight = c(this.dom.scroller).height();
            this.s.viewportRows = parseInt(this.s.viewportHeight / this.s.rowHeight, 10) + 1;
            this.s.dt._iDisplayLength = this.s.viewportRows * this.s.displayBuffer;
            this.s.trace && console.log("Row height: " + this.s.rowHeight + " Viewport height: " + this.s.viewportHeight + " Viewport rows: " + this.s.viewportRows + " Display rows: " + this.s.dt._iDisplayLength);
            if (typeof a == "undefined" || a)
                this.s.dt.oInstance.fnDraw()
        },
    

    I have upgraded the libraries to jquery.dataTables-1.13.7.min.js and dataTables.scroller-2.4.0.min.js.After upgrading I ]observed that the scroller fn is not being called and hence the iDisplayLength value is set to 10 which is default value.

    Could you help me figure out what's wrong with the new libraries and why the scroller isn't getting called?

    Thanks!!

  • allanallan Posts: 63,439Questions: 1Answers: 10,459 Site admin

    Can you link me to a running test case please? That page just has some JS code (which I've never see that subdomain do quite like that before).

    Also, is there a reason you didn't update to DataTables 2. If you are jumping from 1.9 to 1.13, you might as well go to 2, given that 1.x is no longer supported (unless you have a support contract).

    Allan

  • MagizhMagizh Posts: 6Questions: 1Answers: 0

    Sorry I havent attached the test case.I have provided the function from js file in our project which we have used to render the dataTable for your reference.

    We stick with version 1.13.7 since that was the most recent when I started the upgrade.The website states that 1.x is still supported..Is it not the case?

  • allanallan Posts: 63,439Questions: 1Answers: 10,459 Site admin

    Only the latest versions are "officially" supported (i.e. I'm unlikely to patch an issue in 1.x unless it is a security issue).

    Are you able to produce a test case please? I can't debug the JS from the link above.

    Allan

Sign In or Register to comment.