Selecting null values in searchpane gives no results when using serverside data

Selecting null values in searchpane gives no results when using serverside data

jamesj2jamesj2 Posts: 6Questions: 3Answers: 0

I'm using the serverside: true option with the searchpanes plugin. When there is a null option in the search pane it won't give any results when selecting it.

I've created a example repo to replicate the issue. Check the readme.md for instructions on how to set up the app and recreate the issue.

Replies

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @jamesj2 ,

    I've tried to get this running this morning but the script is throwing some errors - I think to do with some needed updates on my side. I'll take a closer look tomorrow and hopefully get it running then.

    Thanks,
    Sandy

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @jamesj2 ,

    That took a lot longer than I was expecting it to, sorry for the delay!

    I've made a fix for this in both the SearchPanes repo as well as the editor library repos. To get this you will need to pull in the code from the nightly version of SearchPanes. You will also need to pull in the latest from this repo, alternatively this will all be released within the next week or two if you can wait.

    Let me know if you run into any more difficulty.

    Thanks,
    Sandy

  • jamesj2jamesj2 Posts: 6Questions: 3Answers: 0

    I'm going to wait for the official release. Thanks for your help!

  • stevevancestevevance Posts: 58Questions: 6Answers: 1
    edited August 2023

    I think this is still an issue.

    I have a lot of fields in my database set to PostgreSQL's null value. I use SearchPanes PHP's render function to relabel these to "[not set]".

    However, selecting these null value options in SearchPanes throws a JS error and causes the loading indicator remain showing.

    The error thrown in the console is, TypeError: null is not an object (evaluating 'item.filter.toString') in datatables.js line 23,949.

    Versions:
    - DataTables 1.13.6
    - SearchPanes: 2.2.0
    - Editor: 2.2.2

  • allanallan Posts: 62,085Questions: 1Answers: 10,180 Site admin

    Could you try the SearchPanes nightly please? I've added a fix for this specific issue.

    Allan

  • stevevancestevevance Posts: 58Questions: 6Answers: 1
    edited August 2023

    @allan I installed the nightly version and the error is no longer thrown (and no errors are thrown), so that seems good.

    My new issue is that the SeachPanes + Server Side Processing doesn't properly filter for null values in the database. Instead it searches for an empty string; see the Editor Debug info below:

    {
    "query":"SELECT COUNT(*) as cnt FROM "ordinances_elms" WHERE "project_type" = :where_0 ",
    "bindings":[
    {
    "name":":where_0",
    "value":"",
    "type":null
    }
    ]
    }
    
  • allanallan Posts: 62,085Questions: 1Answers: 10,180 Site admin

    Sorry - there was a bug in how we were checking for results, which didn't take null values into account. I've committed the fix for PHP (our .NET and Node.js libraries had the same issue and have also had commits to fix the issue).

    To apply, you could modify your existing Editor.php file with that, or just grab the full file and replace the whole thing for what you are using locally.

    There was also a possible out of bounds index error, due to potentially missing information sent from the client-side which has also been fixed. To see that error would have required multiple items selected, including a null value. That will be in the SearchPanes nightly shortly.

    Phew - and with all of that, it should hopefully work well for you now!

    Regards,
    Allan

  • stevevancestevevance Posts: 58Questions: 6Answers: 1

    @allan That change to the Editor.php file has solved this problem. Thank you.

  • allanallan Posts: 62,085Questions: 1Answers: 10,180 Site admin

    Awesome - thanks for letting me know.

    I'll get a release of SearchPanes and Editor out sometime in the near future to have them properly up to date.

    Allan

Sign In or Register to comment.