is there a way to generate a sharable link for datatable that uses searchPane, a code ex. would help - Page 2

is there a way to generate a sharable link for datatable that uses searchPane, a code ex. would help

2

Replies

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    The problem is that the defaultOption searchPanes object is overwritten by the searchPanes.preSelect option. I think you will need to add true as the first parameter in $.extend(). See the jQuery extend() docs for details about deep copying.

    Kevin

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    Sorry, I've not had a chance to look into this yet. It will likely involve encoding a search using array syntax, but it isn't something I've done yet.

    Sorry, I'm swamped with support requests at the moment and I'm not managing to keep up.

    Allan

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    no problem @kthorngren suggestion actually took care of my issue. Thanks!
    I did run into anther issue now that I have upgraded to latest datatable (2.0.2) when I set the displayStart with the searchPane.preSelect in the url, it is not working.
    https://live.datatables.net/kexidave/1/edit

    url:
    https://live.datatables.net/kexidave/1?searchPanes.preSelect=%5B%7B%22rows%22%3A%5B%22Edinburgh%22%2C%22London%22%5D%2C%22column%22%3A2%7D%5D&displayStart=20

    this was working for me on the previous version of datatable (dt-1.13.8) where I was changing the values for displayStart on the url and it would pick the right pagination.

    https://live.datatables.net/hazijoxu/1/edit

    https://live.datatables.net/hazijoxu/1?searchPanes.preSelect=%5B%7B%22rows%22%3A%5B%22Edinburgh%22%2C%22London%22%5D%2C%22column%22%3A2%7D%5D&displayStart=20

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    Looks like the problem happens when searchPanes performs the searches. When it calls draw its reseting back to the first page. Presumably SearchPanes 2.3.0 calls draw() without passing the false parameter to stay on the same page when preselecting. I added these events to both examples to see this:

    $(document).on('select.dt', function () {
      console.log('select');
    });
    
    $('#example').on('draw.dt', function () {
      console.log('draw');
    })
    
    $('#example').on('draw.dt', function () {
      console.log('page', $('#example').DataTable().page.info().page);
    })
    

    DT 2.0.2 output:

    draw
    page 2
    draw
    page 2
    2 x select
    draw
    page 0
    draw
    page 0
    

    https://live.datatables.net/nenozalo/1?searchPanes.preSelect=%5B%7B%22rows%22%3A%5B%22Edinburgh%22%2C%22London%22%5D%2C%22column%22%3A2%7D%5D&displayStart=20

    Where the DT vers 1 has this output:

    draw
    page 2
    draw
    page 2
    draw
    page 2
    select
    draw
    page 2
    select
    

    It stays on page 2 after calling draw.

    https://live.datatables.net/habanozu/1?searchPanes.preSelect=%5B%7B%22rows%22%3A%5B%22Edinburgh%22%2C%22London%22%5D%2C%22column%22%3A2%7D%5D&displayStart=20

    @allan will need to take a look.

    Kevin

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    Thanks! @kthorngren. this isn't really related to my original question but the reason I wanted to upgrade for DT 2.0.2 was because it had the fix for the showing message issue ex. Showing 31 to 26 of 26 programs (filtered from 208 total entries). would there be a way to address that issue without upgrading to DT 2.0.2

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    I'm not familiar with the issue. Was it discussed in this or another thread?

    Maybe open a new thread with this issue.

    Kevin

  • tseoneztseonez Posts: 38Questions: 1Answers: 0
  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    revising this @allan I noticed the latest release 2.0.3 didn't not have a fix for this, you have any workaround or suggestion for this?

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    I believe issue with searchPanes.preSelect resetting to the first page is due to this fix in SearchPanes 2.3.0:

    Triggering a search on a page after the first of the main table, could result in incorrect paging

    See the release notes. I believe this is the fix you are referencing in this thread:
    https://datatables.net/forums/discussion/77999

    Here is a simplified example:
    https://live.datatables.net/salupuke/1/edit

    I don't know of a workaround for this. @allan will need to decide how to handle the combo of searchPanes.preSelect and displayStart.

    Kevin

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    One workaround, which I don't think is a good one, is to use setTimeout() in initComplete to set the paging. For example:
    https://live.datatables.net/qimipaho/1/edit

    As far as I know there is not a way to know when searchPanes has completed its search. I seems to occur after initComplete.

    Code would need to be added to see if displayStart was passed as a parameter and to calculate the page. Use page.info() to get the page length to calculate the page number. Use page() to set the page. It looks like setting the page() to a non-existent page results in landing on page 1.

    Kevin

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    Thanks @kthorngren I tried playing around with initComplete it really isn't working for me as I want the selected paging to remain when I change around the filters in the searchPane.

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    Based on the fix in SearchPanes 2.3.0 each SearchPanes search will go back to the first page. I don't think there is an easy work around for staying on the current page anytime SearchPanes is used.

    Kevin

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    what is the oldest version of SearchPane that I can use with DT 2.0. I am thinking maybe downgrading might help?

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    I believe 2.3.0 is the first release compatible with 2.0. If you use a previous version you might rin into the issue in this thread you linked to.

    Kevin

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    hmm for the thread I linked is related to a bug in DT version 1, and which @allen responded saying it was addressed in DT 2.0.

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    @kthorngren actually I think you were right! It could have been the searchPane older version that was causing the bug in the thread. so I was just playing around with using DT version 1 with searchPane 2.3.0 since the release note for the searchPane 2.3.0 states it should be compatible with DT 1 .

    I have these versions so far

    and am getting this error right now tho, Uncaught TypeError: Cannot read properties of undefined (reading 'apply')

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    I don't think searchPane 2.3.0 is compatible with DataTables 1 even though the release note states that. kept getting "Loading Search Panes" message. as soon as i switch to 2.2.0 the issue goes away

    https://live.datatables.net/covikiwa/1/edit

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    Sorry about that - there is indeed a compatibility issue with DT1. Because DT1 isn't supported any more, I don't have the unit tests running on it, I just check by hand. And I missed that one. Apologies.

    I've committed a fix that should do the job. I'm not at my standard computer atm, so I can't do a full check, but I'll check in the morning that the nightly build carries the change.

    Moreover, there does appear to be an underlying issue in SearchPanes when using preSelect. I don't know what is causing that I'm afraid. If a workaround such as what Kevin suggests does the trick, go with that for now. SearchPanes needs a bit of a reworking.

    Allan

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    One thing - Kevin asked me if there was a way to know when a SearchPane is triggered a search on the main table. Somewhat surprisingly, there isn't I'm afraid. There should really be an event for that.

    For the moment, you'd need to treat all search actions on the host table as potentially coming from SearchPanes or any other source.

    Allan

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    Thanks Allen! I am trying to fix the issue on my production app, so really appreciate Kevin's and yours support on this

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    Hi, when do I get to use the new fix? can I test it using this link

    https://nightly.datatables.net/js/dataTables.min.js

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    The change was in SearchPanes, so https://nightly.datatables.net/searchpanes/js/dataTables.searchPanes.js?2024-03-26 is the file that would carry it. I've added a query parameter just to make sure you get the latest version.

    Allan

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    hmm I am still getting the same error:
    https://live.datatables.net/hudajonu/1/edit

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    Doh - sorry. Just committed this change which should fix that. The nightly will take about 10 minutes before it is up to date, and you might want to change the ? query parameter.

    Allan

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    thanks @allan. sorry still not working for me for some reason. i don't get the error message but the searchPane is not displayed

    the version i am using are - 1.13.11 for datatable, 2.3.0( nightly build ) for searchPane, i picked select 1.7.0 and button 2.4.0

    https://live.datatables.net/fijibija/1/edit

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    Third time is the charm: https://live.datatables.net/fijibija/2/edit . Sorry - apparently I made more DT2 specific changes that I remembered.

    Allan

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    Thanks @allan, it's working for me now. However, I haven't found a workaround for using displayStart while maintaining the current page position as SearchPanes is being used.. For the time being, so I am gonna stick to SearchPane 2.2.0 and hope to upgrade in the future.

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    Reviving this thread to check to see if it has been addressed or would it be addressed in the near future? The problem concerns the combination of searchPanes.preSelect and displayStart, which causes the display to reset to the first page in searchPane version 2.3.0.

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    Sorry that is not something that I've worked on yet. It is in my backlog. I rather suspect this will continue to be present until I can work on a rewrite of SearchPanes (which it is due for).

    Allan

  • tseoneztseonez Posts: 38Questions: 1Answers: 0

    @allan thanks. I will keep checking then

Sign In or Register to comment.