Moving/Recreating the resultsTable_length

Moving/Recreating the resultsTable_length

usedlensusedlens Posts: 15Questions: 5Answers: 1
edited July 2020 in Free community support

I want free control to put the resultsTable_length select box in a 'filters' section. It is changing the returned results, but it does not update the results 1-10 and pagination is not updated to reflect it either.

https://usedlens.co.uk/
Go to filters, changed the 'show entries' filter from 10 to another value

I am sending the length parameter from the select box

I have set lengthChange: false, to stop it appearing

 data: function(data){
        data.pricemin =  $('#pricemin').val();
        data.pricemax =  $('#pricemax').val();
        data.producttype = $("input[name='producttype']:checked").val();
        data.length = $('#resultsTable_length').children("option:selected").val();

and the code for the new select field

                $('#resultsTable_length').change( function() {
                        $('html, body').animate({
                            scrollTop: 150
                        }, 300);
                        resultsTable.draw();
                    } );

I had another idea, I keep lengthChange: true and have the new select box affect the default one

            $('#filterlength').change( function() {
                    $('select[name="resultsTable_length"]').val($(this).children("option:selected").val());
                    $('html, body').animate({
                        scrollTop: 150
                    }, 300);
                    resultsTable.draw();
                } );

Whilst the resultsTable_length selects the matching value, it does not trigger any event.

This question has an accepted answers - jump to answer

Answers

  • usedlensusedlens Posts: 15Questions: 5Answers: 1
    Answer ✓

    Just found the solution lengthChange:true, display:none on the original select box, and add this to my new filter select

    $('#filterlength').change( function() {
            resultsTable.page.len($(this).children("option:selected").val()).draw();
                        } );
    
  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    Yes. You can also use the dom option to remove the original page length control.

    Allan

This discussion has been closed.