SearchPane resets scroll position after selection

SearchPane resets scroll position after selection

aluionescualuionescu Posts: 3Questions: 1Answers: 0
edited March 2024 in Free community support

Thank you for such a useful tool that is the Datatables library.

I created a two column SearchPane using data from the Server-Side and the cascadePanes set to true.

All seem to go well expect that whenever I make a selection in one of the panes, instead of the natural maintaining of the scroll position, I always get a reset and scroll to the top of the pane.

Searching the forum, I see at least one person that has the same issue (https://datatables.net/forums/discussion/comment/219981) and it looks like the example in the Editor (https://editor.datatables.net/examples/extensions/searchPanesCascade.html) is experiencing the same problem.

Could there be an easy fix to maintain the scroll position?

I use the latest version of Datatable (2.0.1) / SearchPanes (2.3.0) / Select (2.0.0) (

Thank you,

Answers

  • aluionescualuionescu Posts: 3Questions: 1Answers: 0

    This is how the basic initialization looks:

    var table = $('#myTable').DataTable({
                processing: true,
                responsive: true,
                serverSide: true,
    
                ajax: {
                    url: 'get-data.php',
                    data: function(d) {
    
                        //  DataTables params request
                        d.search = d.search.value;
                        d.start = d.start;
                        d.length = d.length;
                        if (typeof d.order === 'undefined' || d.order.length === 0) {
                            // Set initial ordering (by score from the server)
                            d.order = [{
                                column: 0,
                                dir: 'asc'
                            }];
                        } else {
                            d.orderColumn = d.order[0].column;
                            d.orderDir = d.order[0].dir;
                        }
                        d.formSearch = initialSearchValue;
                        d.tinut = initialJudetValue;
                        d.sursa = initialSursaValue;
    
                    },
                    dataType: 'json',
                    type: 'GET',
                },
    
                "columnDefs": [
                {
                    searchPanes: {
                        show: true,
                        className: 'filter-table'
                    },
                    targets: [2,3]
                },
                ],
    
                layout: {
                    top1: {
                        searchPanes: {
                            orderable: true,
                            initCollapsed: true,
                            cascadePanes: true,
                            // dtOpts: {
                            //     select: {
                            //         style: 'multi',
                            //     },
                            // }
                        }
                    }
                },  
        }
    
  • ServiceSoftwareServiceSoftware Posts: 10Questions: 4Answers: 0

    Same problem for me with Datatables 2.2.2 and using ServerSide. This would be understandable if (why?) the selected value in the Search Pane were removed. Otherwise this seems to be a usability issue?

  • ServiceSoftwareServiceSoftware Posts: 10Questions: 4Answers: 0

    Using DataTables 2.3.6 and SearchPanes 2.3.5 with serverSide and cascadePanes.

    Search Panes still scroll to top with each click. Has anyone found a work around for this issue?

  • allanallan Posts: 65,517Questions: 1Answers: 10,884 Site admin

    Hi,

    I've just been looking into this and I've committed a fix for the issue. Its a basic workaround, but it should work well until I rewrite SearchPanes, which is something that I hope to move onto soon.

    The nightly version has this fix and it would be great if you could try it out please, and let me know how you get on with it?

    Regards,
    Allan

Sign In or Register to comment.