0 always being passed in Start

0 always being passed in Start

mattpmmattpm Posts: 4Questions: 1Answers: 0

Hi,

for some reason, start is always 0 on the server side even though the paginate buttons are available e.g.
<li class="paginate_button "><a href="#" aria-controls="myTable" data-dt-idx="4" tabindex="0">4</a></li>

Any ideas on why the value is not being passed through?

thanks

Matt

Answers

  • mattpmmattpm Posts: 4Questions: 1Answers: 0
    edited June 2018

    I've been looking at this for hours. Somewhere along the way, the settings._iDisplayStart is not persisted so by the time the _fnDraw method is entered, the value is 0.

    I have an interim "ugly" workaround for the time being where I persist the start value in a module level variable and set oSettings._iDisplayStart to this value but as to why it's losing the value when other values are persisted I'm unsure.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi Matt,

    I'm not clear on what the problem is, probably me being slow. We're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. 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

  • mattpmmattpm Posts: 4Questions: 1Answers: 0
    edited June 2018

    Thanks Colin,

    it's frustrating but I cannot reproduce this issue if I work it up from scratch. This issue has emerged in an existing project due to some change I've made somewhere. I've tried tracing through the changes via source control and nothing leaps out.

    I've further honed in on the issue that when _fnReDraw is called, holdPosition is false so iDisplayStart is set to 0.

    function _fnReDraw( settings, holdPosition )
        {
            var
                features = settings.oFeatures,
                sort     = features.bSort,
                filter   = features.bFilter;
        
            if ( sort ) {
                _fnSort( settings );
            }
        
            if ( filter ) {
                _fnFilterComplete( settings, settings.oPreviousSearch );
            }
            else {
                // No filtering, so we want to just use the display master
                settings.aiDisplay = settings.aiDisplayMaster.slice();
            }
        
    **      if ( holdPosition !== true ) {
                settings._iDisplayStart = 0;
            }**
    

    So, now looking at holdPosition to see why it's not being set to true.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Good luck with that, sounds like you're making progress at least...

    Cheers,

    Colin

  • mattpmmattpm Posts: 4Questions: 1Answers: 0

    Thanks Colin. Sadly, I have to leave it with just hard coded setting holdPosition to true with a comment. I know it's not ideal but that will have to do for now.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    What version of DataTables are you using? Can you show us what API calls you are making or any plug-ins that you might have installed?

    Allan

This discussion has been closed.