$.fn.dataTable.enum not working

$.fn.dataTable.enum not working

DainiusDainius Posts: 1Questions: 1Answers: 0

Hi, I am trying to implement
$.fn.dataTable.enum
but its not working. Here is my code.

var unhandledEventsViewModel = function (params) {
    console.log(params);
    var self = this;

    ko.mapping.fromJS(params, {}, self);

    self.AdditionalText = ko.observable("Loading...");

    //code from https://www.datatables.net/plug-ins/sorting/enum
        var unique = 0;
        var types = $.fn.dataTable.ext.type;
        $.fn.dataTable.enum = function (arr) {
            var name = 'enum-' + (unique++);
            var lookup = window.Map ? new Map() : {};
            for (var i = 0, ien = arr.length; i < ien; i++) {
                lookup[arr[i]] = i;
            }
            // Add type detection
            types.detect.unshift(function (d) {
                return lookup[d] !== undefined ?
                    name :
                    null;
            });
            // Add sorting method
            types.order[name + '-pre'] = function (d) {
                return lookup[d];
            };
        };
    
    $.fn.dataTable.enum(['High', 'Medium', 'Low']);

    setTimeout(function () {
        console.log(params);
        $("#" + params.EventTypes + "table").DataTable({
            order: [[7, "asc"], [3, "asc"]],
            ajax: {
                url: params.Url, dataSrc: ""
            },
            columns: [{data : "ColumnName"},type:"enum"],
...

Answers

This discussion has been closed.