a.toLowerCase is not a function

a.toLowerCase is not a function

jazzyjayjazzyjay Posts: 4Questions: 0Answers: 0
edited December 2009 in Bug reports
When my table contains some empty cells (i.e only some TDs are empty), calling .fnDraw() throws the following error:

a.toLowerCase is not a function
return false})}}};_oExt.oSort={"string-asc":function(a,b){var x=a.toLowerCase();var y=b.toLowerCase();
line 63

File: jquery.dataTables.min.js
Version: 1.5.0

I should mention that the table is being sorted by the column in which empty cells appear when I call fnDraw().

Regards
Juraj

Replies

  • jazzyjayjazzyjay Posts: 4Questions: 0Answers: 0
    Just downloaded latest v1.5.4, bug still there:

    a.toLowerCase is not a function
    var y=b.toLowerCase();return((x
  • jazzyjayjazzyjay Posts: 4Questions: 0Answers: 0
    I've modified the sorting function as follows and it appears to work OK:

    line 76
    [code]
    "string-desc":function(a,b){a=a+''; var x=a.toLowerCase();b=b+'';
    var y=b.toLowerCase();return((xy)?-1:0))}
    [/code]
    J.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi Juraj,

    I'm not seeing this problem with empty cells. Could you possibly post an example showing this issue so I can get a patch in for it?

    Thanks,
    Allan
  • jason.ricejason.rice Posts: 1Questions: 0Answers: 0
    edited December 2009
    I was having the same problem (a is null). My JSON response looks like this:
    [code]
    {
    "sEcho":"3",
    "iTotalRecords":"20",
    "iTotalDisplayRecords":"20",
    "aaData":
    [
    ["1","Scrappy","McGee","*0*6*11*"],
    ["2","Jasons","Rice","*0*6*11*1*"],
    ["3","Skippy","McGee","*0*6*11*1*2*"],
    ["13","Skippy","McGee","*0*6*11*12*"],
    ["12",null,null,"*0*6*11*"],
    ["17","Skippy","McGee","*0*6*11*"],
    ["18",null,null,"*0*6*11*17*"],
    ["19",null,null,"*0*6*11*17*"],
    ["25",null,null,"*0*6*11*17*"],
    ["30",null,null,"*0*6*11*"]
    ]
    }
    [/code]
    The sort buttons only cause a javascript error when clicked on columns that contain a cell with a null value. This is not an issue when an empty string is used in lieu of null.

    Hope this helps.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    HI jason.rice,

    Yes indeed, 'null' will most certainly cause this error. If DataTables thinks that the information in that column is a string, then it will act on it as such. If it is given null, then there are of course no methods or properties attached, and thus the error seen. The way to deal with this is not to use null (what does null mean to a table cell? Empty or not present, or perhaps something else?) but rather use an empty string.

    Hope this clarifies the situation.

    Regards,
    Allan
This discussion has been closed.