TypeError: f is undefined

TypeError: f is undefined

stelcostelco Posts: 3Questions: 1Answers: 0

Hi, I am having an issue with a javascript error on my datatables project. In IE9, Firefox and Chrome, I am getting the following error: TypeError: f is undefined

After searching the forums, it seems to be an issue with sorting and sType.

Here is a jsfiddle of my code:

http://jsfiddle.net/0ya4bdo4/1/

All json data is parsing correctly as the response in browser console shows this. It isnt loading though because of the error.

I believe I need to add the sType to the columns here somewhere? Thanks.

$(document).ready(function () {
    $('#auditable').DataTable({
        "ajax": "js/audi.json",
        "columns": [

            {
                "class": 'details-control',
                "orderable": false,
                "data": null,
                "defaultContent": '',

            },

            { "data": "Model" },
            { "data": "Repayments" },
            { "data": "Term" },
            { "data": "CapID" },

        ],
        "order": [[1, 'asc']]
    });

Answers

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    Five columns defined in the Javascript (plus a trailing comma which would make it six in older IE versions) but only four in the HTML - hence the issue. The two should match: http://jsfiddle.net/0ya4bdo4/2/ .

    Allan

  • stelcostelco Posts: 3Questions: 1Answers: 0

    Thanks for the reply it is working now. I also had to add the .json mime type in my web.config (asp.net)

    <system.webServer>

    <staticContent>
      <mimeMap fileExtension=".json" mimeType="application/json" />
    </staticContent>
    

    </system.webServer>

This discussion has been closed.