This topic contains 1 reply, has 2 voices, and was last updated by Jai Jai 5 months, 1 week ago.

Cannot read property 'length' of undefined


  • satryawiguna
    Participant

    Posts: 4
    Member Reply #17628

    View code:

    <div class=”m-portlet__body”>

    <!–begin: Datatable –>

    <table class=”table table-striped- table-bordered table-hover table-checkable” id=”m_dt_bank”>

    <thead>

    <tr>

    <th>id</th>

    <th>name</th>

    <th>slug</th>

    <th>is_active</th>

    <th>created_by</th>

    <th>modified_by</th>

    <th>Actions</th>

    </tr>

    </thead>

    </table>

    </div>

     

    Component code:

    ngAfterViewInit() {

    this._script.loadScripts(‘app-bank’,

    [‘assets/vendors/custom/datatables/datatables.bundle.js’], true).then(() => {

    var options = {

    responsive: true,

    searchDelay: 500,

    processing: true,

    serverSide: true,

    ajax: {

    url: AppGlobal.BaseUrl + ‘/bank/page’,

    type: ‘POST’,

    headers: AppGlobal.Header.getDatatableRequestOption(),

    map: function (data) {

    alert(‘tai’);

    var dataSet = data;

     

    if (typeof data.rows !== ‘undefined’) {

    dataSet = data.rows;

    }

     

    return dataSet;

    }

    },

    columns: [

    {

    data: ‘id’

    },

    {

    data: ‘name’

    },

    {

    data: ‘slug’

    },

    {

    data: ‘is_active’

    },

    {

    data: ‘created_by’

    },

    {

    data: ‘modified_by’

    },

    {

    data: ‘actions’

    }

    ],

    columnDefs: [

    {

    targets: -1,

    title: ‘Actions’,

    orderable: false,

    render: function (data, type, full, meta) {

    return ‘<span class=”dropdown”>’ +

    ‘ +

    ‘<i class=”la la-ellipsis-h”></i> ‘ +

    ‘ ‘ +

    ‘<div class=”dropdown-menu dropdown-menu-right”> ‘ +

    <i class=”la la-edit”></i> Edit Details ‘ +

    <i class=”la la-leaf”></i> Update Status ‘ +

    <i class=”la la-print”></i> Generate Report ‘ +

    ‘</div> ‘ +

    ‘</span> ‘ +

    ‘ +

    ‘<i class=”la la-edit”></i> ‘ +

    ”;

    },

    }

    ]

    };

     

    (<any>$(‘#m_dt_bank’)).DataTable(options);

    });

     

    }

    • This topic was modified 5 months, 1 week ago by  satryawiguna.
    • This topic was modified 5 months, 1 week ago by  satryawiguna.
    Attachments:
    You must be logged in to view attached files.
    Jai
    Jai
    Keymaster

    Posts: 2700
    Support Staff Reply #17656

    Hi šŸ™‚

    What datatableĀ are you using? Is it mDatatable or DataTables.net?

    In mDatatable, there is not columnDefs option.

    Thanks

Tagged: 

You must be logged in to reply to this topic.