jQWidgets Forums

jQuery UI Widgets Forums Grid Grid filter is throwing 'ae.parseDate is not a function' error

This topic contains 5 replies, has 2 voices, and was last updated by  Dimitar 10 years, 1 month ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author

  • jcwren
    Participant

    I have a grid that has text and drop-down list columns. The grid has ‘filterable: true, autoshowfiltericon: true, showfilterrow: true’ as options. Typing in the search field causes a ‘ae.parseDate is not a function’ exception.

    There appears to be two problems in the filter. The first is that a value in the column such as ‘Limited 10’ is being interpreted as a date by Date(), and returning ‘Mon Oct 01 2001 00:00:00 GMT-0400 (EDT)’ as a value (Chrome Version 42.0.2311.90 under Linux, same behavior under OSX and Windows. Don’t know about other browsers).

    The second is that the filter code is calling a.jqxdataFormat.tryparsedate() if Date() returns ‘NaN’ or ‘Invalid Date’. tryparsedate() is calling ae.parseDate(), which doesn’t exist. Changing all the ‘parseDate’ to ‘parsedate’ fixes the problem.

    But why is the filter trying to test everything that’s not a number or Boolean as a date? Seems like the test should instead be
    if (h.toString() != "NaN" && h.toString() != "Invalid Date") and only process it if Date() thinks it’s a date?


    jcwren
    Participant

    The above fix I mentioned works for the text boxes, but not the drop-down lists.

    In the code below, if i.jqxdataformat.tryparsedate(n) returns null, and ar is not set to true, then an exception is thrown on the ax.setHours(0), which is caught by the try/catch, and then tries to do an.toString() when an is null. The two following changes fix this (in part).

    if (!ar) { –> if (!ar && ax) {

    if (an.toString() != "") { –> if (an && an.toString() != "") {

    There’s still an issue that if the drop-down list column has ‘Limited-10’, it’s being interpreted as a date, and won’t match any values in the column. If I change the drop-down label to ‘Limited Ten’, it now works correctly. It appears there’s *WAY* too much effort trying to interpolate everything into a date. That might explain some of the performance issues with large grids.

    Function that’s throwing the exception:

    try {
        var au = new Date(an);
    
        if (au.toString() == "NaN" || au.toString() == "Invalid Date") {
            an = i.jqx.dataFormat.tryparsedate(an)
        } else {
            an = au
        }
    
        ax = an;
        var ar = false;
    
        if (W != undefined && aa != undefined) {
            if (W.indexOf("t") >= 0 || W.indexOf("T") >= 0 || W.indexOf(":") >= 0 || W.indexOf("f") >= 0) {
                ar = true;
    
                if (am && am.toString().indexOf(":") == -1) {
                    var ai = i.jqx.dataFormat.tryparsedate(am.toString() + ":00", aa);
    
                    if (ai != null) {
                        this.filterdate = ai
                    }
                }
            }
        }
    
        if (!ar) {
            ax.setHours(0);
            ax.setMinutes(0);
            ax.setSeconds(0)
        }
    } catch (ao) {
        if (an.toString() != "") {
            return false
        }
    }
    

    Dimitar
    Participant

    Hello jcwren,

    Please make sure you are using the latest version of jQWidgets (3.8.0). The issue should not be present in it. Please also abstain from posting parts of the widgets’ source code, as this is in violation of the jQWidgets end-user license agreement.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    jcwren
    Participant

    That is 3.8.0, and that issue *is* present.


    jcwren
    Participant

    This jsFiddle (http://jsfiddle.net/jcwren/jadh02qu/) demonstrates the exact problem.

    Set “adult_label = ‘Adult 10′” and an “Uncaught TypeError: Cannot read property ‘toString’ of null” exception occurs (see explanation in original post).

    Set “adult_label = ‘Adult'” and it works correctly.
    Set “adult_label = ‘Adult 10x'” and it also works correctly.
    Set “adult_label = ‘Adult_10′” and it also works correctly.


    Dimitar
    Participant

    Hi jcwren,

    Thank you for your feedback. It seems this issue occurs only in Chrome (not in Firefox or Internet Explorer) and when there is a foreign key column (i.e. “Age”) in the grid. The following example without a foreign key column works fine: http://jsfiddle.net/Dimitar_jQWidgets/fkkd4q1j/. We will investigate this erroneous behaviour and if we confirm it as an issue, we will fix it as soon as possible.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.