SearchBuilder error on empty cells in a column

SearchBuilder error on empty cells in a column

crestATcrestAT Posts: 16Questions: 2Answers: 0

First of all thank you for this awsome and powerful SearchBuilder extension!
Tried to use it and it works great but in some cases it throw an error:

datatables.min.js:876 Uncaught TypeError: Cannot read property 'replace' of null
    at Object.c.initSelect [as init] (datatables.min.js:876)
    at c._clearValue (datatables.min.js:866)
    at HTMLSelectElement.<anonymous> (datatables.min.js:863)
    at HTMLSelectElement.dispatch (jquery.min.js:2)
    at HTMLSelectElement.v.handle (jquery.min.js:2)

Turned out that this happens when I use a column which contains empty cells and I use the condition "Equals" on this column. The conditions "Empty" and "Not Empty" handles such a column without problems so I think "Equals" should/could handle these columns too. Just for clarification, empty means cells with null values, not empty strings...

I use the latest DataTables release 1.10.22 with SearchBuilder 1.0.0, Data source = JSON

Any help is highly appreciated!

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    It seems to be behaving here for me - see Ashton Cox's position field. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

  • crestATcrestAT Posts: 16Questions: 2Answers: 0

    Thank you Colin for the prompt response!

    IMHO the difference is the data source - reading from the HTML table is different to feeding the data via JSON - I suppose for your example the empty position cell will be treated like an empty string but not as null like in my case...?

    Since I'm not sure atm how to change your example to set data via JSON array here an example from the debugging console how my data looks like, maybe this makes it more clear...

    0: Array(4)
    0: "19"
    1: "Allgemein"
    2: null
    3: "Allgemein"
    

    With this null in column 2 the row will be shown if the condition is set to "Empty" without error so I thought it should/could be also handled if I use the condition "Equals"...

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770
    edited October 2020

    I updated Colin's test case with Javascript data. The Position column has "" and the Office column has null. The Position column still works but the null throws the error you indicated.
    http://live.datatables.net/nawinuye/2/edit

    This should give the developers the needed info for a fix.

    Kevin

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Ah, excellent, thanks Kevin for that. I've raised it internally (DD-1714 for my reference) and we'll report back here when there's an update.

    Cheers,

    Colin

  • crestATcrestAT Posts: 16Questions: 2Answers: 0

    Thank you Kevin for your support and Colin for taking care about this issue!

    In the meantime I discovered a similar issue on SearchPanes for the case of null data values which leads also to an error message. @Colin do you want me to open a new report for this since it is off-topic for this case?

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    That's OK, I've raised it as DD-1715 and have registered this thread onto both. It will be probably be the end of the week when it gets looked at, but we'll report back here when either/both are addressed,

    Colin

  • crestATcrestAT Posts: 16Questions: 2Answers: 0

    @Colin Awesome, thanks a lot!

  • colincolin Posts: 15,144Questions: 1Answers: 2,586
    Answer ✓

    This has been fixed - if you run Kevin's example now (it's using the nightly builds so it'll get the latest) you'll notice the error no longer occurs. This will be included in the next release, which will be in the next couple of weeks.

    Colin

  • crestATcrestAT Posts: 16Questions: 2Answers: 0

    Thats really great, thank you very much!

  • crestATcrestAT Posts: 16Questions: 2Answers: 0

    Back again with this issue, unfortunately with the latest release of Searchbuilder (1.0.1) - assuming to include the fix (?) - and Datatables (1.10.23) the problem with null data raised again. The only difference is that there is no longer an error displayed in the console... this applies also to Kevin's test case above -> No matching records found.

    Added a test case here http://live.datatables.net/faqaqaxa/1/edit

    Furthermore the use of the ellipsis plugin leads to a display of the escaped string in the Value select box (maybe I missed somehing here from the docs...?),
    eg Data = Position Condition = Equals than in the Value select one can see the escaped strings.

    Another thing is to display and filter with a footer select 'all' special characters a user can input I struggle with a 'special' case where < and > are in one cell (for this I re-used the ellipsis plugin to escape the characters). Everything is working well (even cells with newline = \n inside but only the before mentioned case is not showing the correct result (selecting the Position footer select for Senior <Javascript> Developer -> No matching records found).
    If you want me to raise a new thread for this please tell me...

    Any hints to solve my issues are highly appreciated, many thanks in advance!

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @crestAT ,

    For null values I've reopened DD-1714 that colin raised previously, I'll take a look at it again at some point in the new year - I'm on holiday at the moment.

    The ellipsis plugin issue is also strange. I've raised an issue internally (DD-1789 for my reference) and will report back here when there is an update. I'll look at the other "special issue" as well as this in the new year at some point too.

    Thanks,
    Sandy

  • sandysandy Posts: 913Questions: 0Answers: 236

    @crestAT 's most recent comment was also placed in a new post, we will track the above there from now on.

    https://datatables.net/forums/discussion/66310/searchbuilder-issues-w-o-ellispsis-plugin#latest

This discussion has been closed.